public static void doCopy(String PrimaryAddress, String NewAddress) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File(PrimaryAddress));
fos = new FileOutputStream(new File(NewAddress));
byte [] buf = new byte[1024];
int len = 0;
while((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
fos.flush();
}
} catch (Exception e) {
System.err.println("文件复制失败!");
}finally{
try {
if(fis != null) {
fis.close();
}
} catch (Exception e2) {
// TODO: handle exception
}
try {
if(fos != null) {
fos.close();
}
} catch (Exception e2) {
// TODO: handle exception
}
}
}
文件的复制
最新推荐文章于 2023-07-24 10:48:57 发布