关于“DataInputStream”

nenu0 nenu0 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
为什么以下的代码从文件读出的数据不正确?输入文件格式“112233”。得到的数据值很大,是“12593 12850 13107”。 WHY!!!

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();
data.readChar();
System.out.print(in + " ");
}
} catch (EOFException eof) {
buff.close();
}
} catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
}
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
nenu0
Java SE 62,620 成员 307,251 内容