public void IOCopy(String path, String path1) { File file = new File(path); File file1 = new File(path1); if (!file.exists()) { System.out.println(file.getName() + "文件不存在"); } else { System.out.println(file.getName()); System.out.println("存在"); } byte[] b = new byte[(int) file.length()]; if (file.isFile()) { try { FileInputStream is = new FileInputStream(file); FileOutputStream ps = new FileOutputStream(file1); is.read(b); ps.write(b); } catch (Exception e) { e.printStackTrace(); } } else if (file.isDirectory()) { if (!file.exists()) file.mkdir(); String[] list = file.list(); for (int i = 0; i < list.length; i++) { this.IOCopy(path + "/" + list[i], path1 + "/" + list[i]); } } }
将指定文件夹下的文件copy到指定的文件夹
最新推荐文章于 2024-09-23 09:24:52 发布