复制单级文件夹

mac2024-06-04  56

package org.westos.demo7; import java.io.*; public class MyTest2 { public static void main(String[] args) throws IOException { //复制整个单级文件夹 FileInputStream in = null; FileOutputStream out = null; File file = new File("C:\\Users\\Administrator\\Desktop\\abc"); File[] files = file.listFiles(); for (File file1 : files) { if (file1.isFile()) { in = new FileInputStream(file + "\\"+file1.getName()); out = new FileOutputStream("E:\\test\\"+file1.getName()); int len = 0; byte[] bytes = new byte[1024 * 8]; while ((len = in.read(bytes)) != -1) { out.write(bytes,0,len); out.flush(); } } } out.close(); in.close(); } }
最新回复(0)