The blanks are filled, below.
Of course, you can use any names for the
arguments of the catch{} clauses.
The blocks have to be in the given order
since FileNotFoundException
is a child class of IOException
Also,
the blocks should actually do something.
try { . . . . } catch( FileNotFoundException nfx ) { } catch( IOException iox ) { }
All that remains is to check the command line arguments. The command line looks like this:
java copyBytes sourceFile to destinationFile
Here is the part of the program that checks that the command line is correct:
public static void main ( String[] args )
{
DataInputStream instr;
DataOutputStream outstr;
if ( _________________ _____ _________________ )
{
System.out.println("java CopyBytes source to destination");
return;
}
. . .
Sadly, there are three blanks which must be filled. Here is a list of possible blank-fillers:
args.length == 3args.length != 3args[1].toUpperCase().equals("TO")!args[1].toUpperCase().equals("TO")&&||Fill the blanks. The error message is written out when the command line is incorrect.