Methods of CharsetEncoder
Table of the methods associated with CharsetEncoder and its description.
Modifier and Type |
Method |
Description |
---|---|---|
float |
averageBytesPerChar() |
Returns the average number of bytes that will be generated for every input character. |
boolean |
canEncode(char c) |
Indicates if the specified character can be encoded by this encoder. |
boolean |
canEncode(CharSequence cs) |
Indicates if the provided character sequence can be encoded by this encoder. |
Charset |
charset() |
Returns the charset that created this encoder. |
ByteBuffer |
encode(CharBuffer in) |
Encodes the remaining data from a single input character buffer into a newly-allocated byte buffer |
CoderResult |
encode(CharBuffer in, ByteBuffer out, boolean endOfInput) |
Writes the results to the specified output buffer after encoding as many characters as possible from the provided input buffer. |
protected abstract CoderResult |
encodeLoop(CharBuffer in, ByteBuffer out) |
Encodes one or more characters into one or more bytes. |
CoderResult |
flush(ByteBuffer out) |
Flushes the encoder. |
protected CoderResult |
implFlush(ByteBuffer out) |
Flushes the encoder. |
protected void |
implReset() |
Clears any internal state specific to a given charset by resetting this encoder. |
boolean |
isLegalReplacement(byte[] repl) |
Indicates if the provided byte array is a valid replacement value for this encoder. |
float |
maxBytesPerChar() |
Returns the maximum number of bytes that can be generated for each input character. |
CharsetEncoder |
reset() |
Resets the encoder, clearing any internal state. |
byte[] |
replacement() |
Returns the replacement value for this encoder. |
CharsetEncoder |
replaceWith(byte[] newReplacement) |
Modifies the replacement value of this encoder. |
Inherited Methods
The Methods included with Charset class are inherited by java.lang.Object .
java.nio.charset.CharsetEncoder Class in Java
For the purpose of character encoding and decoding, java offers a number of classes in the ‘java.nio.charset’ package. The ‘CharsetEncoder’ class of this package performs the important task of encoding. In this article, let us understand this class, its syntax, different methods, and some examples of error handling and optimization techniques.
Contact Us