Question: hello , i need help in this java program , i need to get the file name from the scanner object to know the name

hello , i need help in this java program , i need to get the file name from the scanner object to know the name of the file that i cannot read i tried this but am getting error

try {

sc=new Scanner(new File("Latex1.bib"));

sc=new Scanner(new File("Latex2.bib"));

sc=new Scanner(new File("Latex3.bib"));

sc=new Scanner(new File("Latex4.bib"));

sc=new Scanner(new File("Latex5.bib"));

sc=new Scanner(new File("Latex6.bib"));

sc=new Scanner(new File("Latex7.bib"));

sc=new Scanner(new File("Latex8.bib"));

sc=new Scanner(new File("Latex9.bib"));

sc=new Scanner(new File("Latex10.bib"));

}

catch(FileNotFoundException e) {

System.out.println("Could not open input file "+sc.getName()+" for reading ");

System.out.println("Please check if file exists! Program will terminate after closing any openned files");

if(sc!=null)

sc.close();

System.exit(0);}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!