为什么我将10个数存入记事本,但是读出来出现错误
如题,输入 1 2 3 4 5 6 7 8 9 0的时候,记事本里显示了这几个数是对的,但读取时就变了。。。程序代码:
import *; 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(); } }
[ 本帖最后由 腹黑伸手党 于 2012-10-29 12:59 编辑 ]