1 package FileDemo; 2 3 import java.io.DataInputStream; 4 import java.io.DataOutputStream; 5 import java.io.FileInputStream; 6 import java.io.FileOutputStream; 7 import java.io.IOException; 8 9 public class DataStream {10 11 /**12 * @param args13 * @throws IOException14 */15 public static void main(String[] args) throws IOException {16 17 DataOutputStream dos = new DataOutputStream(new FileOutputStream(18 "data.txt"));19 dos.writeInt(2050);20 dos.close();21 DataInputStream dis = new DataInputStream(new FileInputStream(22 "data.txt"));23 int num = dis.readInt();24 System.out.println("num=" + num);25 dis.close();26 }27 28 }