2012-04-21 1 views

ответ

0

BufferedReader br = ...; 
String line; 
while ((line = br.readLine()) != null) { 
    line = br.readLine(); 
    //do whatever with the data 
    if (line == null) break; 
} 
0

Просто прочитать строку и отказаться от него:

BufferedReader bReader = new BufferedReader(new FileReader("someFileName.txt")); 
String line = null; 

while(true) 
{ 
    //skip the odd line 
    bReader.readLine(); 

    //read an even line 
    line = bReader.readLine(); 

    if(line != null) 
     //do stuff with even line 
    else 
     break; //end of input 
} 
+0

вам нужно проверить на конец файла, т.е. линии == нуль на обоих readlines – ControlAltDel

+0

Первый 'ReadLine()' ничего не хранить в очереди –