Java Methods of FileWriter

Java FileWriter inherits several methods from its superclass, OutputStreamWriter, as well as some methods of its own. Here are some of the methods available in the FileWriter class:

  1. write(int c): This method writes a single character to the output stream.

  2. write(char[] cbuf): This method writes an array of characters to the output stream.

  3. write(String str): This method writes a string to the output stream.

  4. write(char[] cbuf, int off, int len): This method writes a portion of an array of characters to the output stream, starting at the specified off offset and writing up to len characters.

  5. write(String str, int off, int len): This method writes a portion of a string to the output stream, starting at the specified off offset and writing up to len characters.

  6. flush(): This method flushes the output stream, forcing any buffered output to be written to the file.

  7. close(): This method closes the output stream and releases any system resources associated with it.

Note that like all output stream classes, FileWriter is designed to write characters to a stream one at a time. If you need to write a large amount of data at once, you may want to consider using a buffer or a higher-level class such as BufferedWriter.