Hello I'm working on method that is reading a file and outputting something. My code worked before I put my if statement in the code, I can't seem to figure out the exception part with the if statement inside of it. Any help would be greatly appreciated!
public static void reader(String file, String argument) {
File myList = new File(file);
try {
Scanner in = new Scanner(myList);
while (in.hasNextLine()) {
String s = in.nextLine();
if(myList.equals(argument)){
System.out.print(s);
System.out.println();
}
else{
System.out.print("do something");
}
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Aucun commentaire:
Enregistrer un commentaire