public static void main(String[] arguments) {
try {
FileInputStream file = new FileInputStream("400primes.dat");
BufferedInputStream buff = new BufferedInputStream(file);
DataInputStream data = new DataInputStream(buff);
try {
while (true) { short in = data.readShort(); System.out.print(in + " ");
}
}
catch (EOFException eof) {
buff.close();
}
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
}
try {
FileInputStream file = new FileInputStream("400primes.dat");
BufferedInputStream buff = new BufferedInputStream(file);
DataInputStream data = new DataInputStream(buff);
try {
while (true) { short in = data.readShort(); System.out.print(in + " ");
}
}
catch (EOFException eof) {
buff.close();
}
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
}
而每个ACSII码在计算机里站一个字节
readShort();要读16位即2个字节 1的ACSII为31(16进制)
所以读入的是3131(16进制)的数
而十进制数12593就是16进制数3131
不知道我理解的对否?