输入 1 2 3 4 5 6 7 8 9 0的时候,记事本里显示了这几个数是对的,但读取时就变了。。。
import java.io.*;
public class Idu{
public static void main(String[] args ) throws IOException{
DataOutputStream out = new DataOutputStream(new FileOutputStream("gb.txt"));
int units;
long p;
for( int i = 0;i<10;i++){
System.out.println("输入第"+(i+1)+"个数:");
units = System.in.read();
p = System.in.read();
p = System.in.read();
out.writeInt(units);
}
out.close();
DataInputStream in = new DataInputStream(new FileInputStream("gb.txt"));
int unit;
for( int i = 0;i<10;i++){
unit = in.readInt();
System.out.println(unit);
}
in.close();
}
}