public class CharsetConverter
extends java.lang.Object
| Constructor and Description |
|---|
CharsetConverter(java.nio.charset.Charset fromCharset,
java.nio.charset.Charset toCharset)
Creates a new charset converted that decodes/encodes bytes in the
specified non-null from/to charset objects specified.
|
CharsetConverter(java.nio.charset.Charset fromCharset,
java.nio.charset.Charset toCharset,
boolean ignoreBOM)
Creates a new charset converted that decodes/encodes bytes in the
specified non-null from/to charset objects specified.
|
| Modifier and Type | Method and Description |
|---|---|
java.nio.ByteBuffer |
convert(java.nio.ByteBuffer from)
Convert a byte buffer by decoding using the fromCharset and encoding
using the toCharset.
|
java.nio.ByteBuffer |
convert(java.nio.CharBuffer from)
Converts a char buffer to a byte buffer using the toCharset.
|
java.lang.String |
getToCharsetName()
Get charset name of to charset used to encode
|
public CharsetConverter(java.nio.charset.Charset fromCharset,
java.nio.charset.Charset toCharset,
boolean ignoreBOM)
fromCharset - fromCharsettoCharset - toCharsetignoreBOM - - true to ignore any byte order marks written by the UTF-16
charset and omit them from all return byte bufferspublic CharsetConverter(java.nio.charset.Charset fromCharset,
java.nio.charset.Charset toCharset)
fromCharset - fromCharsettoCharset - toCharsetpublic java.lang.String getToCharsetName()
public java.nio.ByteBuffer convert(java.nio.CharBuffer from)
throws FileEncoderException
from - fromBuffer.position() for starting
array offset, Buffer.limit() for number of bytes to
read, and ByteBuffer.array() for the byte[] itself.FileEncoderException - on errorpublic java.nio.ByteBuffer convert(java.nio.ByteBuffer from)
throws FileDecoderException,
FileEncoderException
Any remaining bytes that couldn't be converted are stored locally until the next call to . The from buffer specified will be joined with the underflow from a previous call on subsequent calls to .
from - - byte buffer to convertBuffer.position() for starting
array offset, Buffer.limit() for number of bytes to
read, and ByteBuffer.array() for the byte[] itself.FileEncoderException - on errorFileDecoderException - on error