Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions

Question

Q .1. Different ways of testing the present adulterants ?

Answered: 1 week ago

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago

Question

1. Traditional and modern methods of preserving food Articles ?

Answered: 1 week ago

Question

What is sociology and its nature ?

Answered: 1 week ago