I want the user to enter a filename on the command line. If they don't enter any, I should print information says file was not processed and exit out. Here is my try catch block
try{
parser.openFile(args[0]);
if(parser.getCounter() == 3)
{
System.out.println("File was processed: true");
}
else
{
System.out.println("File was processed: false. Missing information.");
}
//found = true;
}
catch (IOException e)
{
e.printStackTrace();
System.out.println("File was processed: false. Re-enter filename.");
//fName = keyboard.nextLine();
}
The openFile method is in my class, and it is here, in case anyone needs it:
public void openFile (String filename)throws IOException{
fis = new FileInputStream(filename);
br = new BufferedReader(new InputStreamReader(fis));
String thisLine;
thisLine = br.readLine();
while(thisLine != null)
{
lines.add(thisLine);
thisLine = br.readLine();
}
}
Somehow "File was processed: false. Re-enter filename." does not printed out when there is not filename in the command line. Can anyone help me please?