Java Utililty Methods Byte Array Decode

List of utility methods to do Byte Array Decode

Description

The list of methods to do Byte Array Decode are organized into topic(s).

Method

Stringdecode(String encoding, byte[] bytes)
decode
if (encoding == null) {
    return new String(bytes, "UTF-8");
} else {
    return new String(bytes, encoding);
Stringdecode(String encoding, byte[] data)
Decodes a byte array from specified encoding to a unicode String.
if (data != null) {
    if (encoding == null)
        return new String(data);
    try {
        return new String(data, encoding);
    } catch (UnsupportedEncodingException e) {
return null;
StringdecodeBytes(byte[] data, String encoding)
Returns the UTF-8 string corresponding to the specified bytes.
try {
    return new String(data, encoding);
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("Error decoding bytes with " + encoding, e);
ObjectdecodeObject(byte[] bytes)
decode Object
ByteArrayInputStream bais = null;
ObjectInputStream ois = null;
try {
    bais = new ByteArrayInputStream(bytes);
    ois = new ObjectInputStream(bais);
    return ois.readObject();
} finally {
    if (ois != null) {
...
ObjectdecodeObject(final byte[] bytes)
decode Object
final ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
final ObjectInputStream stream = new ObjectInputStream(byteStream);
final Object result = stream.readObject();
stream.close();
return result;
StringdecodeRequestParameter(String string, String encoding, byte[] buffer)
Given a parameter string and the name of a character encoding, fixes the string.
if (encoding == null)
    return string;
if (string == null)
    return null;
int stringLength = string.length();
if ((buffer == null) || (stringLength > buffer.length))
    buffer = new byte[stringLength];
string.getBytes(0, stringLength, buffer, 0);
...
StringdecodeString(byte[] bytearr)
decode String
int utflen = bytearr.length;
char[] chararr = new char[utflen];
int c, char2, char3;
int count = 0;
int chararr_count = 0;
while (count < utflen) {
    c = (int) bytearr[count] & 0xff;
    if (c > 127)
...
StringdecodeString(byte[] data)
Get an instance of TranscoderUtils.
String rv = null;
try {
    if (data != null) {
        rv = new String(data, charset);
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
return rv;
StringdecodeString(byte[] data)
decode String
try {
    return new String(data, "MACROMAN");
} catch (UnsupportedEncodingException uee) {
    StringBuffer sb = new StringBuffer(data.length);
    for (byte b : data) {
        if (b >= 0)
            sb.append((char) b);
        else
...
StringdecodeString(byte[] stringBytes)
decode String
return decodeString(stringBytes, 0, (stringBytes == null) ? 0 : stringBytes.length);