Answer:
- The
intvalue inansweris transformed intochars (and appended to the string). - 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 on the Web.
Constructors
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.
Methods
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.
When you write() characters to a file,
you are asking the operating system to write to the disk,
which might not do the work until later.
The flush() method ensures that all data is actually sent to the disk.
QUESTION 11:
Why not do a flush() after each write() to be
sure that all the data is written to the disk?