FileReader reader = new FileReader("d:\\UnderTest\\AVS\\tester.txt");
char ch;
int x;
while( ( x = reader.read() ) != -1 ) {
// I use the following statement to detect EOL
if( Character.toString((char)x) == System.getProperty("line.separator") ) {
System.out.println("new line encountered !");
} System.out.print( (char)x );
}
在这段代码中,if 语句永远不会起作用,尽管tester.txt
有 2 个句子写在新行上。为什么呢 ?