Skip to content
- 그림파일 저장 위치 지정
|
public static final String IMG_DIR = System.getProperty("user.dir") + "\\img\\"; |
- 파일 복사 함수 생성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public void f_Copy(String src, String dst) { BufferedInputStream in = null; BufferedOutputStream out = null; System.out.println(src); System.out.println(dst); try { in = new BufferedInputStream(new FileInputStream(src)); out = new BufferedOutputStream(new FileOutputStream(dst)); int c; while((c = in.read()) != -1) { out.write(c); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } try { if(in != null) { in.close(); } if(out != null) { out.close(); } } catch (Exception e) { // TODO: handle exception } } |
- 파일 복사 함수 호출 : FileDialog 이용
|
case "복사": FileDialog dlg = new FileDialog(this, "파일열기", FileDialog.LOAD); dlg.setVisible(true); String src = dlg.getDirectory() + dlg.getFile(); if(src != null) { String dst = IMG_DIR + "10001.png"; f_Copy(src, dst); System.out.println(src + " " + dst); } break; |
error: Content is protected !!