@NotThreadSafe
public final class Coder
extends Object
Simplifies the use of a CharSet encoder / decoder.
Constructor and Description |
---|
Coder()
Constructs an instance.
|
Coder(Charset charset)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
String |
decode(byte[] bytes)
Decodes a bytes array to a tring.
|
String |
decode(byte[] bytes,
int offset,
int length)
Decodes a bytes array to a String.
|
byte[] |
encode(String string)
Encodes a String to a bytes array.
|
Charset |
getCharset()
Gets the character set for encoding / decoding.
|
void |
setCharset(Charset charset)
Sets the character set for encoding / decoding.
|
public Coder()
public Coder(@Nonnull Charset charset)
charset
- The Charset used for encoding / decoding.@Nonnull @CheckReturnValue public String decode(@Nonnull byte[] bytes)
bytes
- The bytes array.@Nonnull @CheckReturnValue public String decode(@Nonnull byte[] bytes, int offset, int length)
bytes
- The bytes array.offset
- The offset at which to start decoding.length
- The number of bytes to decode.@Nonnull @CheckReturnValue public byte[] encode(@Nonnull String string)
string
- The String.@Nonnull @CheckReturnValue public Charset getCharset()
public void setCharset(@Nonnull Charset charset)
charset
- A Charset.Copyright © 2003-2019 Serge Brisson. All Rights Reserved.