Witam!
Wymieniony poniżej program pokazuje co drugą linię, oraz po zakończeniu wyświetla wymieniony w tytule błąd.
Kod:
public static ArrayList<String> LinesToArrayList(File file)
{
ArrayList<String> ar = new ArrayList<String>();
try {
//Scanner
Scanner scanner = new Scanner(file);
//Loop
while (scanner.hasNextLine())
{
System.out.println(scanner.nextLine());
ar.add(scanner.nextLine());
}
//Close scanner
scanner.close();
}
catch (FileNotFoundException e) {
System.out.println(ErrorMessage.defaultErrorMsg(1));
}
return ar;
}