Java Utililty Methods DataInputStream to Object

List of utility methods to do DataInputStream to Object

Description

The list of methods to do DataInputStream to Object are organized into topic(s).

Method

byte[]deserialiseByteArray(DataInputStream is, int max_length)
deserialise Byte Array
int len = deserialiseLength(is, max_length);
byte[] data = new byte[len];
is.read(data);
return (data);
byte[][]deserialiseByteArrayArray(DataInputStream is, int max_length)
deserialise Byte Array Array
int len = deserialiseLength(is, max_length);
byte[][] data = new byte[len][];
for (int i = 0; i < data.length; i++) {
    data[i] = deserialiseByteArray(is, max_length);
return (data);
intdeserialiseLength(DataInputStream is, int max_length)
deserialise Length
int len;
if (max_length < 256) {
    len = is.readByte() & 0xff;
} else if (max_length < 65536) {
    len = is.readShort() & 0xffff;
} else {
    len = is.readInt();
if (len > max_length) {
    throw (new IOException("Invalid DHT data length: max=" + max_length + ",actual=" + len));
return (len);
intdeserializeInt(DataInputStream din)
deserialize Int
return din.readInt();
int[]deserializeIntArray(DataInputStream in)
Deserializes an array of ints.
int len = in.readInt();
if (len == -1) {
    return null;
int[] array = new int[len];
for (int i = 0; i < len; i++) {
    array[i] = in.readInt();
return array;
StringdeserializeString(DataInputStream din)
deserialize String
String str;
if (deserializeHeaderString(tagString, din))
    str = din.readUTF();
else
    str = null;
deserializeTrailerString(tagString, din);
return str;
voiddeserializeTrailerString(String str, DataInputStream din)
deserialize Trailer String
String s2 = din.readUTF();
if (!s2.equals("]"))
    throw new IOException("bogus serialization trailer");