import java.io.DataInputStream;
import java.io.DataOutput;import java.io.DataOutputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class Test07 {
public static void main(String[] args) throws FileNotFoundException { //为什么需要首先定义一个null DataInputStream dis=null; DataOutputStream dos=null; FileInputStream fis=new FileInputStream("D:\\新建文件夹\\IMG_4013.JPG"); dis=new DataInputStream(fis); FileOutputStream fos=new FileOutputStream("D:\\新建文件夹\\aaa.JPG"); dos=new DataOutputStream(fos); try { int temp=dis.read(); while(temp!=-1){ dos.write(temp); temp=dis.read(); } System.out.println("录入成功"); fis.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); }finally{ try { if (dis!=null) { dis.close(); } if (dos!=null) { dos.close(); } } catch (Exception e2) { e2.printStackTrace(); }}
}}