文件copy

 /**
* @param srcpic 复制前文件
* @param despic 复制后文件
*/
public static void copyPic(String srcpic, String despic) {
File file1 = new File(srcpic);
if (file1.length() == 0) {
return;
}
File file2 = new File(despic);
byte[] b = new byte[(int) file1.length()];
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream(file1);
//没有指定文件则会创建
out = new FileOutputStream(file2);
//read()--int,-1表示读取完毕
while (in.read(b) != -1) {
out.write(b);
}
out.flush();
in.close();
out.close();

} catch (Exception e) {
e.printStackTrace();
}
}
posted @ 2021-01-21 15:39  我没有出家  阅读(57)  评论(0编辑  收藏  举报