package lianxi802; import java.io.*; public class Demo02 { public static void main(String[] args) { DataInputStream dis = null; InputStream is = null; DataOutputStream dos = null; OutputStream os = null; try { is = new FileInputStream("g:/p1.png"); dis = new DataInputStream(is); os = new FileOutputStream("g:/newp1.png"); dos = new DataOutputStream(os); int num; while ((num = dis.read()) != -1) { dos.write(num); } System.out.println("已完成!"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { dos.close(); os.close(); dis.close(); is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }