import java.io.*; public class Test_A10 { public static void main(String[] args){ int data[]={100,101,102,103,104,105}; int p; try{ FileOutputStream file1 = new FileOutputStream("dest.txt"); DataOutputStream dataOutputStream = new DataOutputStream(file1); for(int i=0; i<data.length; i++){ // 将循环从1改为0 dataOutputStream.writeInt(data[i]); } dataOutputStream.close(); // 将关闭流的位置移至循环外部 FileInputStream file2 = new FileInputStream("dest.txt"); DataInputStream dataIn = new DataInputStream(file2); for(int i=data.length-1; i>=0; i--){ p = dataIn.readInt(); System.out.println(" " + p); } System.out.println(); dataIn.close(); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }