The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 5 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a Java program that prompts the user for a filename and attempts to open the file as follows:
Scanner infile = new Scanner(new FileInputStream(filename));
If there an exception thrown as a result, the program should prompt the user to reenter the
filename until a valid filename exists. (Make sure to have a textfile as part of the project to open. It
should be in the main project folder, not in any of the project subfolders.) Go to the Java API (link in
Blackboard) and look up the constructor for the FileInputStream class to determine the exceptions
that the constructor throws.
Note that your program must import both the FileInputStream class, AND the class of the exception type that the constructor of this class throws. Therefore, you must either use:
import java.io.* - to import ALL of the classes in the package
or
import java.io.FileInputStream;
import.java.io.ExceptionClassName
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------