최대 1 분 소요

public static void copyFile(String src, String dest){

long fsize = 0;

try{

FileInputStream fin = new FileInputStream(src);

FileOutputStream fout = new FileOutputStream(dest);

FileChannel inc = fin.getChannel();

FileChannel outc = fout.getChannel();

//복사할 file size

fsize = inc.size();

inc.transferTo(0, fsize, outc);

inc.close();

outc.close();

fin.close();

fout.close();

/-

//입출력을 위한 버퍼를 할당한다.

ByteBuffer buf = ByteBuffer.allocateDirect(1024);

while(true){

if(inc.read(buf)==-1)

break;

buf.flip();

outc.write(buf);

buf.clear();

}

*-

}

catch(Exception e){

e.printStackTrace();

}

}