A good answer might be:

  1. The int value in answer is transformed into chars (and appended to the string).
  2. Then, as the data is written to disk, the chars are transformed into 8-bit UTF.

Summary of Class FileWriter

Here is a list of some of the constructors and methods used with FileWriter. All of the methods are inherited from its ancestors. For a complete list of methods refer to the Java documentation, on your disk (if you downloaded it), or here: http://java.sun.com/j2se/1.3/docs/api/index.html


FileWriter(String fileName) 
   An IOException is thrown 
   if the file cannot be created.
FileWriter(String fileName, boolean append)            
   An IOException is thrown 
   if the file cannot be opened for appending.


public void close() throws IOException
    Flush the stream and close the file.

public void flush() throws IOException
    Flush the stream.

public void write(String str) throws IOException
    Write a string.

Data might not go immediately to the disk after a write(). The flush() method ensures that data previously written is sent to the disk. The second write() method sends a portion of a string to the file.


Could the user of a program enter a name for the file about to be created?