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:
write(int c)
: This method writes a single character to the output stream.write(char[] cbuf)
: This method writes characters from thecbuf
character array to the output stream.write(char[] cbuf, int off, int len)
: This method writes up tolen
characters from thecbuf
character array, starting at the specifiedoff
offset, to the output stream.write(String str)
: This method writes the characters of the specifiedstr
string to the output stream.write(String str, int off, int len)
: This method writes up tolen
characters from the specifiedstr
string, starting at the specifiedoff
offset, to the output stream.flush()
: This method flushes the output stream, meaning that any buffered characters are written to their intended destination.close()
: This method closes the output stream and releases any system resources associated with it.getEncoding()
: This method returns the name of the character set being used by thisOutputStreamWriter
.