Java OutputStreamWriter

Java OutputStreamWriter is a class that writes characters to an OutputStream and encodes them into bytes using a specified character set. It is a bridge between character streams and byte streams.

Here are some of the methods available in the OutputStreamWriter 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. flush(): This method flushes the output stream, meaning that any buffered characters are written to their intended destination.

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

  8. getEncoding(): This method returns the name of the character set being used by this OutputStreamWriter.