import java.io.*;
public class xxx {
public static void main(String[] args) throws IOException {
FileReader fs = new FileReader("xxx.txt");
int t = fs.read();
int count = 0;
while (t!=-1) {
count++;
t = fs.read();
}
System.out.println(count);
}
}Java:为什么在读取文本文件情况下 n被认为是2个字符?
考虑到xxx.txt包含:
a
b b
cccd
我只是困惑,为什么在 “下一行” 被认为是2个字符?我手动计算了10个字符(包括空白),但结果是12.
谢谢。