Question: The following program uses command line arguments to create a Scanner object to read from a file. Fill in the blanks to complete this Java

 The following program uses command line arguments to create a Scanner

The following program uses command line arguments to create a Scanner object to read from a file. Fill in the blanks to complete this Java class, public class Demo{public static void main(String|| args) throws FileNotFoundException{//check and read command line argument for file name String fileName; if (args. _________ > 0) {fileName = ________;} else {fileName = _________;} _______ fileReader = openFile(fileName);} private static String promptForFileName() {System.out.println('Enter the file name: "); Scanner keyln = new Scanner(Systen.in); return keyln.next();} private static Scanner openFile(________ fileMame) throws FileNotFoundException {File file - new File(________); while (!file.exists()) {file = new File(________);} return new Scanner(____);}}

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!