public class DataInOutTest { public static void main(String[] args) { DataOutputStream dos=null; DataInputStream dis=null; FileInputStream fis=null; FileOutputStream fos=null; try{ fis = new FileInputStream("D:\\doc\\User.class"); dis = new DataInputStream(fis); fos =new FileOutputStream("D:\\doc\\newUser.class"); dos =new DataOutputStream(fos); int temp; while (((temp=dis.read())!=-1)){ fos.write(temp); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try{ if (dis!=null) dis.close();; if (fis!=null) fis.close(); if (fos!=null) fos.close(); if (dos!=null) dos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
标签:fis,fos,输入输出,示例,new,close,DataInOut,null,dis From: https://www.cnblogs.com/max-hou/p/18448232