public static void copyFile(String srcPath,String descPath){
try (
FileInputStream fis = new FileInputStream(srcPath);
FileOutputStream fos = new FileOutputStream(descPath);
BufferedInputStream bis = new BufferedInputStream(fis);
BufferedOutputStream bos = new BufferedOutputStream(fos);
){
byte[] data = new byte[1024];
int len;
while ((len = bis.read(data)) != -1) {
bos.write(data,0,len);
}
} catch (Exception e) {
e.printStackTrace();
}
}
如何使用Java复制一个文件
最新推荐文章于 2022-12-12 11:01:04 发布