首页 > 其他 > 详细

u盘拷贝

时间:2019-09-05 09:24:10      阅读:67      评论:0      收藏:0      [点我收藏+]
package one._1;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;110.180.200.229
public class Demo10 {
 public static void Copy(File path) throws IOException {
  // 目标复制的到地方
  File des = new File("c:\\123");
  des.mkdirs();
  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 {
  // U盘位置
  File f = new File("G:\\");
  Copy(f);
 }
}

u盘拷贝

原文:https://www.cnblogs.com/rong123/p/11462848.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!