zoukankan      html  css  js  c++  java
  • u盘拷贝

    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);
     }
    }
  • 相关阅读:
    yum---Linux软件安装与管理
    Python Cheetah01
    Python 改变字体颜色
    DenyHosts安装及配置
    Python 文件I/O
    Python 列表(List)
    Python 字符串
    Python 循环语句
    Python 条件语句
    Python 系统性能信息模块psutil
  • 原文地址:https://www.cnblogs.com/rong123/p/11462848.html
Copyright © 2011-2022 走看看