星空网 > 软件开发 > Java

单个文件复制

/****

* 复制单个文件

* @param oldPath String原文件路径 如:c:/fqf.txt

* @param newPath String 复制后路径 如:f:/fqf.txt

*/

public void copyFile(String oldPath,String newPath) {

     try {

          int bytesum=0;

          int byteread=0;

        File oldfile=new File(oldPath);

      if(oldfile.exists()){//文件存在时

    InputStream inStream=new FileInputStream(oldPath);

    FileOutputStream fs=new FileOutputStream(newPath);

    byte[] buffer=new byte[1444];

    int length;

  while((byteread=inStream.read(buffer))!=-1){

    bytesum+=byteread;//字节数 文件大小

    System.out.println(bytesum);

    fs.write(buffer,0, byteread);

    }

    inStream.close();

  }

} catch (Exception e) {

  System.out.println("单个文件复制出错");

  e.printStackTrace();

  }

}




原标题:单个文件复制

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

中国到西非海运:https://www.goluckyvip.com/tag/92530.html
柬埔寨海运中国:https://www.goluckyvip.com/tag/92531.html
柬埔寨中国海运:https://www.goluckyvip.com/tag/92532.html
中国海运柬埔寨:https://www.goluckyvip.com/tag/92533.html
中国新德里海运:https://www.goluckyvip.com/tag/92534.html
中国利比亚海运:https://www.goluckyvip.com/tag/92535.html
龙脊梯田在哪?从桂林到那里需要多久?周围还有什么好玩的?:https://www.vstour.cn/a/407241.html
韩国电商初创企业面临冲击,平台关闭量增加37%!:https://www.kjdsnews.com/a/1842104.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流