ファイルを開き、ファイルの最後に到達するまで readLine() を使用してすべての行をループする必要があります。
-- ファイルをトラバースするときに一貫性を保っていると思います。情報を保存して後で使用する場合は、何らかのデータ構造を使用することを検討します。
これをたどると、単純な正規表現で行をチェックして、それがラベル名であるかどうかを確認できます。そうでない場合は、' ' (スペース文字) に基づいて行を分割すると、配列で返されます。次に、一貫したサイズに基づいてサイズを確認します。
基本的な擬似コード:
int consistentSize = 5; // assume you have a size in mind
while ( (line = readLine()) != EOF)
{
// check for if label, if it's a simple name, you won't really need a regex
if (line == label)
{
// not sure if you want to do any consistency checking in here
} else {
String[] currLine = line.split(' ');
bool consist = true;
// now loop through currLine and do a check if each character is a number
for (int i = 0; i < currLine.size(); i++)
{
// can't remember java function for this (isNum() I think)
if (!currLine[i].isNum) { consist = false; break; }
}
// if got past this, the row has all numbers, therefore it is ok
// could easily add another array to keep track of rows that didn't have valid numbers and suhc
if (currLine.size() < consistentSize) System.out.println("row "+j + " is inconsistent");
}
}
各行に予想されるサイズがわからない場合は、別のループを追加し、最も一般的なサイズを見つけて、一致しないものを特定するロジックを追加することもできます。一貫性チェックがどれほど複雑である必要があるかはわかりません。