public class AdvancedOutputStreamWriter extends FilterWriter
通常、ASCII の範囲に含まれない文字は、java.io.OutputStreamWriter を
利用して相互に文字コード変換した場合、各文字エンコーディングの
Unicode に対するマッピングの相違により、本来その文字エンコーディングにおいて
存在する文字であってもコード不明を意味する「?」に置き換えられてしまう
ことがあります。
いわゆる、この文字化けに対して、文字コード変換前に、
対象となる文字エンコーディングに対する Unicode の正しい文字に
置換することで、いくつかの文字については正しく文字コード変換することが
できます。
このクラスでは、この方式により文字化けを回避します。
文字化けに対する文字のマッピングおよび対応する文字エンコーディングに
関しては、jp.co.intra_mart.common.aid.jdk.util.charset.CharacterEncoder
クラスの仕様に準じます。
jp.co.intra_mart.common.aid.jdk.util.charset.CharacterEncoder
out
コンストラクタと説明 |
---|
AdvancedOutputStreamWriter(OutputStream out)
デフォルトの文字エンコーディングを使う AdvancedOutputStreamWriter を作成します。
|
AdvancedOutputStreamWriter(OutputStream out,
Charset cs)
与えられた文字エンコーディングを使う AdvancedOutputStreamWriter を作成します。
|
AdvancedOutputStreamWriter(OutputStream out,
CharsetEncoder enc)
与えられた文字エンコーディングエンコーダを使う AdvancedOutputStreamWriter を作成します。
|
AdvancedOutputStreamWriter(OutputStream out,
String charsetName)
指定された文字エンコーディングを使う AdvancedOutputStreamWriter を作成します。
|
AdvancedOutputStreamWriter(OutputStreamWriter writer)
OutputStreamWriter をフィルタリングする新しい AdvancedOutputStreamWriter を作成します。
|
修飾子とタイプ | メソッドと説明 |
---|---|
String |
getCharacterEncoding()
このオブジェクトが対象としている文字エンコーディング名を返します。
|
OutputStreamWriter |
getOutputStreamWriter()
このオブジェクトの基礎出力となっている java.io.OutputStreamWriter を返します。
|
void |
write(char[] cbuf,
int off,
int len)
文字の配列の一部を書き込みます。
|
void |
write(int c)
単一の文字を書き込みます。
|
void |
write(String str,
int off,
int len)
文字列の一部を書き込みます。
|
close, flush
public AdvancedOutputStreamWriter(OutputStream out, String charsetName) throws UnsupportedEncodingException, ResourceNotFoundException, ResourceFormatException, IOException
out
- 基礎となる出力ストリームcharsetName
- サポートされる charset の名前UnsupportedEncodingException
- 指定された文字エンコーディングがサポートされていない場合NullPointerException
- 引数が null の場合ResourceNotFoundException
- 対象となる文字エンコーディングに対応する設定がない場合IOException
- 設定の読み込みエラーResourceFormatException
- 設定に不整合がある場合public AdvancedOutputStreamWriter(OutputStream out) throws ResourceFormatException, ResourceNotFoundException, IOException
out
- 基礎となる出力ストリームNullPointerException
- 引数が null の場合ResourceNotFoundException
- 対象となる文字エンコーディングに対応する設定がない場合IOException
- 設定の読み込みエラーResourceFormatException
- 設定に不整合がある場合public AdvancedOutputStreamWriter(OutputStream out, Charset cs) throws IOException, ResourceFormatException, ResourceNotFoundException
out
- 基礎となる出力ストリームcs
- サポートされる CharsetNullPointerException
- 引数が null の場合ResourceNotFoundException
- 対象となる文字エンコーディングに対応する設定がない場合IOException
- 入出力エラーResourceFormatException
- 設定に不整合がある場合public AdvancedOutputStreamWriter(OutputStream out, CharsetEncoder enc) throws ResourceFormatException, IOException, ResourceNotFoundException
out
- 基礎となる出力ストリームenc
- 文字エンコーディングエンコーダNullPointerException
- 引数が null の場合ResourceNotFoundException
- 対象となる文字エンコーディングに対応する設定がない場合IOException
- 設定の読み込みエラーResourceFormatException
- 設定に不整合がある場合public AdvancedOutputStreamWriter(OutputStreamWriter writer) throws ResourceNotFoundException, IOException, ResourceFormatException
なお、このオブジェクトが対応する文字エンコーディングは、 java.io.OutputStreamWriter#getEncoding() の返す値によって 決定します。 java.io.OutputStreamWriter#getEncoding() が null を返す場合、 このコンストラクタは NUllPointerException をスローして オブジェクトの作成に失敗します。
writer
- 基本となるストリームを提供する java.io.OutputStreamWriter オブジェクトNullPointerException
- 引数が null の場合ResourceNotFoundException
- 対象となる文字エンコーディングに対応する設定がない場合ResourceFormatException
- 設定に不整合がある場合IOException
- 設定の読み込みエラーpublic String getCharacterEncoding()
public void write(char[] cbuf, int off, int len) throws IOException
write
クラス内 FilterWriter
cbuf
- 書き込む文字のバッファoff
- 文字の読み込み開始オフセットlen
- 書き込む文字数IOException
- 入出力エラーが発生した場合public void write(int c) throws IOException
write
クラス内 FilterWriter
c
- 書き込む文字を指定する intIOException
- 入出力エラーが発生した場合public void write(String str, int off, int len) throws IOException
write
クラス内 FilterWriter
str
- 書き込まれる文字列off
- 文字の読み込み開始オフセットlen
- 書き込む文字数IOException
- 入出力エラーが発生した場合public OutputStreamWriter getOutputStreamWriter()
Copyright © 2012 NTT DATA INTRAMART CORPORATION