A good answer might be:


FileWriter Constructors

Here is an excerpt from the example program. The constructor for FileWriter is passed a String which contains the name for the file. When the FileWriter is constructed, a new disk file is created in the current directory and given the name "reaper.txt". If there is already a file with that name, it will be replaced. The stream that writes to the file is writer.

public static void main ( String[] args ) throws IOException
  String fileName = "reaper.txt" ;

  FileWriter writer = new FileWriter( fileName );
    . . .

The two constructors that interest us are:

 FileWriter(String fileName) 
 FileWriter(String fileName, boolean append) 

The second form of the constructor has an argument, append. If append is true, the constructor will open an existing file will for writing without destroying its contents. If the file does not exist, it will be created.


What happens if the file name is not legitimate?