| java.lang.Object com.lutris.util.Convert
Convert | public class Convert (Code) | | Various conversion methods.
These methods are mostly used to convert internal java data
fields into byte arrays or strings for use over the network
or in 8 bit ASCII fields.
See Also: HexEncoder See Also: Base64Encoder |
Method Summary | |
final public static byte[] | fromBase64String(String s) Performs RFC1521 style Base64 decoding of Base64 encoded data.
The output is a byte array containing the decoded binary data.
The input is expected to be a normal Unicode String object.
Parameters: s - The Base64 encoded string to decode into binary data. | final public static String | toBase64String(byte[] bytes) Performs RFC1521 style Base64 encoding of arbitrary binary data.
The output is a java String containing the Base64 characters representing
the binary data. | final public static String | toBase64String(byte[] bytes, char[] chars) Performs encoding of arbitrary binary data based on a 6 bit
alphabet. | final public static String | toHexString(long value, int len, char pad) Converts a long integer to an unsigned hexadecimal String. | final public static String | toHexString(byte[] bytes) Converts an arbitrary array of bytes to ASCII hexadecimal string
form, with two hex characters corresponding to each byte. |
fromBase64String | final public static byte[] fromBase64String(String s)(Code) | | Performs RFC1521 style Base64 decoding of Base64 encoded data.
The output is a byte array containing the decoded binary data.
The input is expected to be a normal Unicode String object.
Parameters: s - The Base64 encoded string to decode into binary data. An array of bytes containing the decoded data. |
toBase64String | final public static String toBase64String(byte[] bytes)(Code) | | Performs RFC1521 style Base64 encoding of arbitrary binary data.
The output is a java String containing the Base64 characters representing
the binary data. Be aware that this string is in Unicode form, and
should be converted to UTF8 with the usual java conversion routines
before it is sent over a network. The output string is guaranteed
to only contain characters that are a single byte in UTF8 format.
Also be aware that this routine leaves it to the caller to break
the string into 70 byte lines as per RFC1521.
Parameters: bytes - The array of bytes to convert to Base64 encoding. An string containing the specified bytes in Base64encoded form. |
toBase64String | final public static String toBase64String(byte[] bytes, char[] chars)(Code) | | Performs encoding of arbitrary binary data based on a 6 bit
alphabet. The output is a java String containing the encoded
characters representing the binary data. Be aware that this
string is in Unicode form, and should be converted to UTF8 with
the usual java conversion routines before it is sent over a
network. The alphabet passed in via chars is used
without further checks, it's the callers responsibility to set
it to something meaningful.
Parameters: bytes - The array of bytes to convert to Base64 encoding. Parameters: chars - The alphabet used in encoding. Must containexactly 65 characters: A 6 bit alphabet plus onepadding char at position 65. An string containing the specified bytes in Base64encoded form. |
toHexString | final public static String toHexString(long value, int len, char pad)(Code) | | Converts a long integer to an unsigned hexadecimal String. Treats
the integer as an unsigned 64 bit value and left-pads with the
pad character of the caller's choice.
Parameters: value - The long integer to convert to a hexadecimal string. Parameters: len - The total padded length of the string. If the numberis larger than the padded length, then this lengthof the string will be the length of the number. Parameters: pad - The character to use for padding. Unsigned hexadecimal numeric string representing the specified value. |
toHexString | final public static String toHexString(byte[] bytes)(Code) | | Converts an arbitrary array of bytes to ASCII hexadecimal string
form, with two hex characters corresponding to each byte. The
length of the resultant string in characters will be twice the
length of the specified array of bytes.
Parameters: bytes - The array of bytes to convert to ASCII hex form. An ASCII hexadecimal numeric string representing thespecified array of bytes. |
|
|