热门

最新

红包

立Flag

投票

同城

我的

发布
qq_51216522
慵懒的小熊x
4 年前
trueqq_51216522

许久没有更新了,水一下动态,最近太忙了,活成了写手的生活(每天都是读书笔记为伴)

CSDN App 扫码分享
分享
评论
2
打赏
  • 复制链接
  • 举报
下一条:
将一个文件夹内所有文件复制的后续//遍历File数组,得到每一个File对象 for(File file:filearray){ copyFoder(file,newFoder); } }else { //说明是文件,直接复制 File newFile = new File(destfile,srcfile.getName()); copyFile(srcfile,newFile); } } private static void copyFile(File srcfile,File destfile) throws IOException{ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcfile)); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destfile)); byte[] bt = new byte[1024]; int len ; while((len = bis.read(bt)) != -1){ bos.write(bt,0,len); } bis.close(); bos.close(); }}
立即登录