彭于晏们请看看这串代码
FileInputStream stream=new FileInputStream("Game\\\\a.txt");
System.out.println((char) stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
System.out.println((char)stream.read());
stream.close();
读取的文件中只有五个字节abcde。
最后运行的结果是:
a
b
c
d
e
13
10
-1
就想问问吴彦祖们,这个13和10是啥啊。
该回答引用chatgpt:
结果中的 13 和 10 是 ASCII 码对应的特殊字符。具体解释如下:
13 对应的是回车符(Carriage Return,简写为 CR),ASCII 码中的换行符。
10 对应的是换行符(Line Feed,简写为 LF),ASCII 码中的换行控制字符。
-1 表示文件末尾(End of File,简写为 EOF),表示已经读取到文件的末尾。