A good answer might be:The program could be modified so that it opens the input file for appending, using the constructor: FileWriter(String fileName, boolean append) |
C-style Input LoopHere is the loop from the copyFile() method. The logic of the loop is correct and it works efficiently.
Here is the same loop written in a style that is commonly used with the "C" programming language. This loop also works for Java:
The key to understanding this is to understand
that an assignment statement is an expression
and has a value.
That value is the value that is assigned to the variable.
So this:
This may be more bother than it is worth, but programmers familiar with C are likely to use this style, so you will see it often. |
QUESTION 14:Will this form of the loop work correctly with an empty file? Click Here after you have answered the question |