public static void copyFile(String fromPath, String toPath) { try { int bytesum = 0; int byteread = 0; File oldfile = new File(fromPath); if (oldfile.exists()) { InputStream inStream = new FileInputStream(fromPath); FileOutputStream fs = new FileOutputStream(toPath);//这句报错,说toPath拒绝访问,为啥?</span> byte[] buffer = new byte[1444]; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; System.out.println(bytesum); fs.write(buffer, 0, byteread); } inStream.close(); fs.close(); } } catch (Exception e) { e.printStackTrace(); } }
java 原封不动文件复制
最新推荐文章于 2023-06-12 20:41:23 发布