Can anyone debug this for me please? Java code to copy package debugmeone; impor
ID: 3853269 • Letter: C
Question
Can anyone debug this for me please? Java
code to copy
package debugmeone;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ReadTextFile {
private Scanner input; // Ignore the hint given by NetBeans
public void openFile() {
try
{
input = new Scanner( new File("accountrecords.txt"));
}
catch(Exception e)
{
System.out.println("Something bad just happened here.");
System.exit(707);
}
catch( FileNotFoundException fnfe)
{
System.out.println("Error - File Not Found: accountrecords.txt");
System.exit(100);
}
}
}
Explanation / Answer
package debugmeone;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ReadTextFile {
private Scanner input; // Ignore the hint given by NetBeans
public void openFile() {
try
{
input = new Scanner( new File("accountrecords.txt"));
}
catch( FileNotFoundException fnfe)
{
System.out.println("Error - File Not Found: accountrecords.txt");
System.exit(100);
}
catch(Exception e)
{
System.out.println("Something bad just happened here.");
System.exit(707);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.