📜  Java.io.OutputStreamWriter类

📅  最后修改于: 2020-11-15 02:48:11             🧑  作者: Mango


介绍

Java.io.OutputStreamWriter类是从字符流到字节流的桥梁。使用指定的字符集将写入其中的字符编码为字节。

类声明

以下是Java.io.OutputStreamWriter类的声明-

public class OutputStreamWriter
   extends Writer

领域

以下是Java.io.OutputStreamWriter类的字段-

  • protected Object lock-这是用于同步此流上的操作的对象。

类的构造函数

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.

方法继承

此类从以下类继承方法-

  • Java.io.作家
  • Java对象