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 - toCharset - ignoreBOM - - 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 - toCharset - public java.lang.String getToCharsetName()
public java.nio.ByteBuffer convert(java.nio.CharBuffer from)
throws FileEncoderException
from - Buffer.position() for starting
array offset, Buffer.limit() for number of bytes to
read, and ByteBuffer.array() for the byte[] itself.FileEncoderExceptionpublic 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 convert(ByteBuffer). The from buffer specified
will be joined with the underflow from a previous call on subsequent
calls to convert(ByteBuffer).
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.FileEncoderExceptionFileDecoderExceptionCopyright © 2022 Perforce Software. All Rights Reserved.