我有一个文件*.txt档里面内容是这样
In this below-sea-level basin, steady drought and record summer heat make
Death Valley a
land of extremes. Yet, each extreme has a striking contrast. Towering peaks
are frosted with
winter snow. Rare rainstorms bring vast fields of wildflowers. Lush oases
harbor tiny fish
and refuge for wildlife and humans. Despite its morbid name, a great
diversity of life survives
in Death Valley.
在程式码里面用
while(bufferedReader.readLine() != null)
{
System.out.println(bufferedReader.readLine());
}
结果只会显示第二行和第四行
land of extremes. Yet, each extreme has a striking contrast. Towering peaks
are frosted with
and refuge for wildlife and humans. Despite its morbid name, a great
diversity of life survives
但是如果用
String str = null;
while((str=bufferedReader.readLine()) != null)
{
System.out.println(str);
}
就可以显示文件全部的内容,但是请问这两种方式在逻辑上好像
没什么不一样????请问为什么会有这样的状况?