复制图片
package cn.home; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyPicture { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("C:\\str.png"); DataInputStream dis = new DataInputStream(fis); FileOutputStream fos = new FileOutputStream("E:\\大胡\\nstr.png"); DataOutputStream dos = new DataOutputStream(fos); int num = -1; while((num=dis.read())!=-1) { dos.write(num); } fos.flush(); System.out.println("已完成,可到文件查看"); dos.close(); fos.close(); dis.close(); fis.close(); } }