Java.io.OutputStreamWriter Class

Advertisements


Introduction

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.

Class declaration

Following is the declaration for Java.io.OutputStreamWriter class:

public class OutputStreamWriter
  extends Writer

Field

Following are the fields for Java.io.OutputStreamWriter class:

  • protected Object lock -- This is the object used to synchronize operations on this stream.

Class constructors

S.N.Constructor & Description
1OutputStreamWriter(OutputStream out)
This creates an OutputStreamWriter that uses the default character encoding.
2OutputStreamWriter(OutputStream out, Charset cs)
This creates an OutputStreamWriter that uses the given charset.
3OutputStreamWriter(OutputStream out, CharsetEncoder enc)
This creates an OutputStreamWriter that uses the given charset encoder.
4OutputStreamWriter(OutputStream out, String charsetName)
This creates an OutputStreamWriter that uses the named charset.

Class methods

S.N.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.

Methods inherited

This class inherits methods from the following classes:

  • Java.io.Writer

  • Java.io.Object




Advertisements
Advertisements