Re: [问题]请问关于文件读取行的问题!!!

楼主: qrtt1 (有些事,有时候。。。)   2020-01-24 10:33:26
※ 引述《SST2000 (BMW 428i)》之铭言:
: 我有一个文件*.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);
: }
: 就可以显示文件全部的内容,但是请问这两种方式在逻辑上好像
: 没什么不一样????请问为什么会有这样的状况?

Links booklink

Contact Us: admin [ a t ] ucptt.com