Question: Do I need to add a try - catch block to throw the FileNotFoundException in this code? If so , what would the finished, compilable
Do I need to add a trycatch block to throw the FileNotFoundException in this code? If so what would the finished, compilable code for MyCat.java look like?
package csexceptions;
import java.util.Scanner;
import java.ioFile;
import java.ioFileNotFoundException;
A simpler version of the Unix cat command.
public class MyCat
Entry point for the application. Exactly zero or one commandline arguments are expected.
If a filename is given as an argument, then the program should print the contents of that
file to standard output. If a single dash ie is given as an argument, then
the program should print the contents of standard input.
@param args the commandline arguments
public static void mainString args
String filename args;
if filenameequals
Printer.printStdInLines;
else
File file new Filefilename;
Printer.printFileLinesfile;
if
main
MyCat
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
