zoukankan      html  css  js  c++  java
  • java复制文件操作

    // File srcFolder=new File("c:\demo");
    // File destFolder=new File("d:\test");
    // if(!destFolder.exists()){
    // destFolder.mkdir();
    //
    // }
    // File[] fileArray=srcFolder.listFiles();
    //
    // for(File file:fileArray){
    // System.out.println(file);
    //
    // String name=file.getName();
    // File newFile=new File(destFolder,name);
    // System.out.println(newFile);
    // // copyFile(file,newFile);
    // }
    }

    private static void copyFile(File file, File newFile) throws IOException {
    BufferedInputStream bis=new BufferedInputStream(new FileInputStream(file));
    BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(newFile));
    byte[] bys=new byte[1024];
    int len=0;

    while((len=bis.read(bys))!=-1){
    bos.write(bys,0,len);

    }
    bos.close();
    bis.close();

    }
    }

  • 相关阅读:
    商品表(spu)、规格表(sku)设计
    Links
    About
    AFO
    口胡题
    NOIP2014 飞扬的小鸟
    CSP2019 Emiya 家今天的饭
    CSP2019 括号树
    CSP-J2019 加工零件
    CSP-J2019 纪念品
  • 原文地址:https://www.cnblogs.com/liumin-txgt/p/13426424.html
Copyright © 2011-2022 走看看