The Java.io.OutputStreamWriter class is a bridge from character streams to byte streams. Characters written to it are encoded into bytes using a specified charset.
Following is the declaration for Java.io.OutputStreamWriter class −
public class OutputStreamWriter extends Writer
Following are the fields for Java.io.OutputStreamWriter class −
protected Object lock − This is the object used to synchronize operations on this stream.
Sr.No. | Constructor & Description |
---|---|
1 | OutputStreamWriter(OutputStream out) This creates an OutputStreamWriter that uses the default character encoding. |
2 | OutputStreamWriter(OutputStream out, Charset cs) This creates an OutputStreamWriter that uses the given charset. |
3 | OutputStreamWriter(OutputStream out, CharsetEncoder enc) This creates an OutputStreamWriter that uses the given charset encoder. |
4 | OutputStreamWriter(OutputStream out, String charsetName) This creates an OutputStreamWriter that uses the named charset. |
Sr.No. | Method & Description |
---|---|
1 | void close()
This method closes the stream, flushing it first. |
2 | void flush()
This method flushes the stream. |
3 | String getEncoding()
This method returns the name of the character encoding being used by this stream. |
4 | void write(char[] cbuf, int off, int len)
This method writes a portion of an array of characters. |
5 | void write(int c)
This method writes a single character. |
6 | void write(String str, int off, int len)
This method writes a portion of a string. |
This class inherits methods from the following classes −