public class Encoding extends Object
| Constructor and Description |
|---|
Encoding() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkEncoding(String encoding)
Checks whether given encoding (name) is supported.
|
static byte[] |
fromHex(String hex)
Converts given
String in HEX representation to byte array representation. |
static byte[] |
getBytes(String text)
|
static byte[] |
getBytes(String text,
String encoding)
Converts given
String with given encoding to byte array representation. |
static String |
getString(byte[] text)
|
static String |
getString(byte[] text,
String encoding)
Converts given byte array to
String with given encoding. |
static String |
toHex(byte[] bytes)
Converts given byte array into
String in HEX representation. |
public static final String DEFAULT
public static String toHex(byte[] bytes) throws IllegalArgumentException
String in HEX representation.bytes - bytes to be convertedIllegalArgumentException - possible exception if input is null or cannot be convertedpublic static byte[] fromHex(String hex) throws IllegalArgumentException
String in HEX representation to byte array representation.hex - HEX string input to be convertedIllegalArgumentException - possible exception if input is null or cannot be convertedpublic static void checkEncoding(String encoding) throws IllegalArgumentException
encoding - encoding to checkIllegalArgumentException - possible exception if encoding is null or not supportedpublic static byte[] getBytes(String text, String encoding) throws IllegalArgumentException
String with given encoding to byte array representation.
It is recommended to check your encoding via checkEncoding(String).text - text to be convertedencoding - encoding of textIllegalArgumentException - possible exception if text is null or encoding is not supportedpublic static byte[] getBytes(String text)
text - text to be convertedIllegalArgumentException - possible exception if text is null or encoding is not supportedpublic static String getString(byte[] text, String encoding) throws IllegalArgumentException
String with given encoding.
It is recommended to check your encoding via checkEncoding(String).text - text bytes to be convertedencoding - encoding for outputIllegalArgumentException - possible exception if text bytes are null or encoding is not supportedpublic static String getString(byte[] text)
text - text bytes to be convertedIllegalArgumentException - possible exception if text bytes are null or encoding is not supportedCopyright © 2014. All rights reserved.