public static Object readObject(ClassLoader classLoader, DataInput in) throws IOException {
        byte type = in.readByte();
        if (type == 0) {
            return null;
        } else if (type == 1) {
            return in.readLong();
        } else if (type == 2) {
            return in.readInt();
        } else if (type == 3) {
            return in.readUTF();
        } else if (type == 4) {
            return in.readDouble();
        } else if (type == 5) {
            return in.readFloat();
        } else if (type == 6) {
            return in.readBoolean();
        } else if (type == 8) {
            return new Date(in.readLong());
        } else if (type == 9) {
            byte[] buf = new byte[in.readInt()];
            in.readFully(buf);
            return buf;
        } else if (type == 10) {
            int len = in.readInt();
            byte[] buf = new byte[len];
            in.readFully(buf);
            try (ObjectInputStream oin = newObjectInputStream(classLoader, new ByteArrayInputStream(buf))) {
                return oin.readObject();
            } catch (ClassNotFoundException e) {
                throw new IOException(e);
            }
        } else {
            throw new IOException("Unknown object type=" + type);
        }
    }
Reads a Map of Serializable key and value pairs. This method will return
<tt>null</tt> if the Map written to the stream was <tt>null</tt>.

@param in the input stream.
@param map a Map of Serializable key and value pairs.
@param loader class loader to use to build elements inside of the serialized collection.
@throws IOException if an error occurs.
@return the number of elements added to the collection.
xmppserver/src/main/java/org/jivesoftware/util/cache/DefaultExternalizableUtil.java