これは私のコードです
public static void main(String[] args) {
File source = //
Scanner s = null;
int lineNumber =0;
ArrayList<ArrayList<Integer>> tagsArray = new ArrayList<>();
try {
s= new Scanner(source);
while (s.hasNext()) {
String[] cols = s.nextLine().split(" ");
for (int i = 0; i < cols.length; i++) {
if (cols[i].equals("1"))
tagsArray.get(i).add(lineNumber);
}
lineNumber++;
}
} catch (Exception e) {
// TODO: handle exception
}
}
forステートメントを削除すると、テキストファイル全体が読み取られますが、使用すると最初の行のみが読み取られるのはなぜですか?