private static void Copy(File oldfile, String newPath) {
try {
int bytesum = 0;
int byteread = 0;
if (oldfile.exists()) {
InputStream inStream = new FileInputStream(oldfile);
FileOutputStream fs = new FileOutputStream(newPath);
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread;
fs.write(buffer, 0, byteread);
}
inStream.close();
TimeUnit.SECONDS.sleep(1);
}
} catch (Exception e) {
System.out.println("error ");
e.printStackTrace();
}
}
java复制文件至指定文件夹
最新推荐文章于 2024-04-17 05:18:29 发布