Java Methods of Writer

ht‮/:spt‬/www.theitroad.com

Java Writer is an abstract class for writing character streams, and it provides several methods to write character data to different destinations.

Here are some of the methods available in the Writer class:

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

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

  3. write(char[] cbuf, int off, int len): This method writes up to len characters from the cbuf character array, starting at the specified off offset, to the output stream.

  4. write(String str): This method writes the characters of the specified str string to the output stream.

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

  6. append(char c): This method appends a single character to the output stream and returns the writer itself.

  7. append(CharSequence csq): This method appends the characters of the specified csq character sequence to the output stream and returns the writer itself.

  8. append(CharSequence csq, int start, int end): This method appends the specified range of characters from the csq character sequence to the output stream and returns the writer itself.

  9. flush(): This method flushes the output stream, meaning that any buffered characters are written to their intended destination.

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