将一个文件夹内所有文件复制的后续//遍历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(); }}