ne or more command-line arguments are accepted as well as outputting a message when no command-line arguments are p

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 7E: (File creation) Write a C++ program that creates an array containing the integer numbers 60, 40, 80,...
icon
Related questions
Question

How do change the code so that one or more command-line arguments are accepted as well as outputting a message when no command-line arguments are provided by the user? The expected behavior is that the program should print the files, in order, to standard output, effectively concatenating the contents of the supplied files.

File Edit
20
21
22
public static void main(String[] args) {
try {
String filename =
Scanner input
args[0];
null;
%3D
23
%3D
24
if (filename.equals("-")) {
Printer.printStdInLines();
} else {
File file = new File(filename);
Printer.printFilelines(file);
}
} catch (ArrayIndexOut0fBoundsException aioobe) {
System.err.pr intin("MyCat:
} catch (FileNotFoundException fnfe) {
System.out.println("The file was not found");
} // if
%3D
25
26
27
28
%3D
29
30
31
+ aioobe.toString( ));
32
33
5 34
35
36
37
} // main
38
39 } // MyCat
WS Abbrev)
Transcribed Image Text:File Edit 20 21 22 public static void main(String[] args) { try { String filename = Scanner input args[0]; null; %3D 23 %3D 24 if (filename.equals("-")) { Printer.printStdInLines(); } else { File file = new File(filename); Printer.printFilelines(file); } } catch (ArrayIndexOut0fBoundsException aioobe) { System.err.pr intin("MyCat: } catch (FileNotFoundException fnfe) { System.out.println("The file was not found"); } // if %3D 25 26 27 28 %3D 29 30 31 + aioobe.toString( )); 32 33 5 34 35 36 37 } // main 38 39 } // MyCat WS Abbrev)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr