go to previous page   go to home page   go to next page

Answer:

Yes.


Text File Copy Program

DOS window showing copy program

The next example program copies a source text file to a destination text file. An already existing file with the same name as destination file will be destroyed. The names of the source and destination come from the command line. It looks like this:

java CopyMaker original to copy

The illustration shows this working in a command prompt window. Notice how the original file and the copy have the same number of bytes.

Most operating systems come with a user interface that includes a file copy command. The order of the source file and the destination file differs between operating systems. Getting them backwards might be disastrous! Our program requires the word "to" in the command line to ensure that the user knows the correct order.

The program will use a FileReader and a BufferedReader for input and a FileWriter and a BufferedWriter for output.


QUESTION 7:

Can this copy program be used to copy a Microsoft Word document?