我需要能够读取文件的每一行多个参数,因此for循环。在第一次之后,它似乎不再读它们,似乎跳过了试验声明。有任何想法吗?我敢肯定,我错过了一些愚蠢的东西,但一直在玩它,不幸的是时间不在我身边。ReadLine - 执行两次?
for (int j = 0; j < ags.length; j++){
try{
String nameFromFile = null;
BufferedReader InputReader = new BufferedReader(new InputStreamReader(System.in));
while ((nameFromFile = InputReader.readLine()) != null) {
// Do stuff
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
你有什么异常? –
在循环之前打印'ags.length'。 – Maroun
ags的长度是多少? –