复制文件
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyFileDemo { public static void main(String[] args) { try( FileInputStream fis=new FileInputStream("E:\\abc\\xxx\\1.png"); FileOutputStream fos=new FileOutputStream("E:\\abc\\xxx\\2.png"); ) { int len=0; byte[] bytes=new byte[1024]; while((len=fis.read(bytes))!=-1){ //System.out.println(len); fos.write(bytes,0,len); } }catch(IOException e){ System.out.println(e); } } }