A good answer might be:

Yes.

Skeleton Program

The program must work correctly with an empty file. This may seem dumb, but there is no reason to have a program break when it is used in an unexpected fashion. Here is the copy program with pieces left out:

class CopyMaker
{
   String sourceName, destName;
   BufferedReader source;
   BufferedWriter dest;
   String line;

   private boolean openFiles()  // return true if files open, else false
   {
   }

   private boolean copyFiles()  // return true if copy worked, else false
   {
   }

   private boolean closeFiles()  //return true if files close, else false
   {
   }

   public boolean copy(String src, String dst )
   {
     sourceName = src ;
     destName   = dst ;
     return openFiles() && copyFiles() && closeFiles();
   }
}

public class CopyTextFile
{
  public static void main ( String[] args ) 
  {
    if ( args.length == 3 && args[1].toUpperCase().equals("TO") )
      new CopyMaker().copy(args[0], args[2]); // create an object, use its
                                              // copy method.
    else
      System.out.println("java CopyTextFile source to destination");
  }
}

Rather than write one big main() it is convenient to define an object who's several methods implement the steps in copying files. The methods easily could be reused in a GUI version of the program.

The main() method is concerned with collecting information from the user. If the information looks correct, it creates a temporary CopyMaker object (using the default constructor) and calls its copyFiles() method. If the information is not correct a reminder message is written to the user.

QUESTION 9:

Look at this statement in copy():

     return openFiles() && copyFiles() && closeFiles();

If openFiles() returns false because a file failed to open, will copyFiles() and closeFiles() be called?

Click Here after you have answered the question