java.io
クラス OutputStreamWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.OutputStreamWriter

public class OutputStreamWriter
extends Writer

OutputStreamWriter は文字ストリームからバイトストリームへの橋渡しの役目を持ち、文字を書き込んで、それを指定された文字エンコーディングに従ってバイトに変換します。使用されるエンコーディングは、名前で指定するか、またはプラットフォームのデフォルトをそのまま使うこともできます。

write() メソッドを呼び出すたびに、指定された文字に対してエンコーディングコンバータが呼び出されます。結果として生成されたバイトは、バッファに蓄積されてから基本となる出力ストリームに書き込まれます。このバッファのサイズは指定できますが、ほとんどの場合、デフォルトのサイズで十分です。write() メソッドに渡される文字はバッファに入らないので注意してください。


クラス java.io.Writer から継承したフィールド
lock
 
コンストラクタの概要
OutputStreamWriter(OutputStream os)
          デフォルトの文字エンコーディングを使う OutputStreamWriter を作成します。
OutputStreamWriter(OutputStream os, String enc)
          指定された文字エンコーディングを使う OutputStreamWriter を作成します。
 
メソッドの概要
 void close()
          ストリームを閉じます。
 void flush()
          ストリームをフラッシュします。
 void write(char[] cbuf, int off, int len)
          文字の配列の一部を書き込みます。
 void write(int c)
          単一の文字を書き込みます。
 void write(String str, int off, int len)
          文字列の一部を書き込みます。
 
クラス java.io.Writer から継承したメソッド
write, write
 
クラス java.lang.Object から継承したメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

OutputStreamWriter

public OutputStreamWriter(OutputStream os)
デフォルトの文字エンコーディングを使う OutputStreamWriter を作成します。
パラメータ:
out - OutputStream

OutputStreamWriter

public OutputStreamWriter(OutputStream os,
                          String enc)
                   throws UnsupportedEncodingException
指定された文字エンコーディングを使う OutputStreamWriter を作成します。
パラメータ:
out - OutputStream
enc - サポートされる文字エンコーディングの名前
例外:
UnsupportedEncodingException - 指定された文字エンコーディングがサポートされていない場合
メソッドの詳細

write

public void write(int c)
           throws IOException
単一の文字を書き込みます。
オーバーライド:
クラス Writer 内の write
例外:
IOException - 入出力エラーが発生した場合

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
文字の配列の一部を書き込みます。
オーバーライド:
クラス Writer 内の write
パラメータ:
cbuf - 書き込む文字のバッファ
off - 文字の読み込み開始オフセット
len - 書き込む文字数
例外:
IOException - 入出力エラーが発生した場合

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
文字列の一部を書き込みます。
オーバーライド:
クラス Writer 内の write
パラメータ:
str - 書き込まれる文字列
off - 文字の読み込み開始オフセット
len - 書き込む文字数
例外:
IOException - 入出力エラーが発生した場合

flush

public void flush()
           throws IOException
ストリームをフラッシュします。
オーバーライド:
クラス Writer 内の flush
例外:
IOException - 入出力エラーが発生した場合

close

public void close()
           throws IOException
ストリームを閉じます。
オーバーライド:
クラス Writer 内の close
例外:
IOException - 入出力エラーが発生した場合