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

    public static void copyFile(File sourceFile, File targetFile){
    try {
    //新建文件输入流并对它进行缓冲
    FileInputStream input = new FileInputStream(sourceFile);
    BufferedInputStream inBuff=new BufferedInputStream(input);

    //新建文件输出流并对它进行缓冲
    FileOutputStream output = new FileOutputStream(targetFile);
    BufferedOutputStream outBuff=new BufferedOutputStream(output);

    //缓冲数组
    byte[] b = new byte[1024 * 5];
    int len;
    while ((len =inBuff.read(b)) != -1) {
    outBuff.write(b, 0, len);
    }
    //刷新此缓冲的输出流
    outBuff.flush();
    //关闭流
    inBuff.close();
    outBuff.close();
    output.close();
    input.close();
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

  • 相关阅读:
    token
    跨域问题???
    简单使用express
    深拷贝 浅拷贝
    node表单提交初知识!
    11.29
    11.28
    11.27
    11.26每日总结
    11.25每日总结
  • 原文地址:https://www.cnblogs.com/loveLearning/p/2682213.html
Copyright © 2011-2022 走看看