复制文件

public class FileUtil {

/**
*  复制文件
*  @param from 原文件
*  @param to 目标文件
*/
public static void copyFile(String from, String to)
throws  FileNotFoundException, IOException {
FileChannel
fChannel = new FileInputStream(from).getChannel(),
tChannel = new FileOutputStream(from).getChannel();

fChannel.transferTo(0, fChannel.size(), tChannel);
//或者tChannel.transferFrom(fChannel, 0, fChannel.size());
}
}

你可能感兴趣的:(文件)