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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started