重複の可能性:
入力からのみ特定の行を読み取りますか?
BufferedReader を使用している場合、ファイルから奇数行をすべてスキップする方法はありますか?
重複の可能性:
入力からのみ特定の行を読み取りますか?
BufferedReader を使用している場合、ファイルから奇数行をすべてスキップする方法はありますか?
行を読んで破棄するだけです。
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
}
BufferedReader br = ...;
String line;
while ((line = br.readLine()) != null) {
line = br.readLine();
//do whatever with the data
if (line == null) break;
}