Java 文件复制函数:一个参数是原文件,一个是目的文件,简单实用
public static void copyFile(String source, String destination) {
try {
FileInputStream fis = new FileInputStream(source);
FileOutputStream fos = new FileOutputStream(destination);
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
fis.close();
fos.close();
System.out.println("File copied successfully!!");
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}