Java Utililty Methods Class Load from File

List of utility methods to do Class Load from File

Description

The list of methods to do Class Load from File are organized into topic(s).

Method

Tdeserialize(Class expectedType, byte[] data)
deserialize
try {
    ObjectInputStream out = new ObjectInputStream(new ByteArrayInputStream(data));
    Object o = out.readObject();
    out.close();
    if (!(expectedType.isAssignableFrom(o.getClass()))) {
        throw new IllegalStateException("Unexpected type: " + o.getClass());
    return (T) o;
...
Tdeserialize(Class classOfT, byte[] bytes)
deserialize
ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes);
ObjectInputStream objectIn = new ObjectInputStream(byteIn);
return (T) objectIn.readObject();
Tdeserialize(Class clazz, File file)
deserialize
ObjectInputStream ois = null;
try {
    ois = new ObjectInputStream(new FileInputStream(file));
    return (T) ois.readObject();
} finally {
    if (ois != null) {
        ois.close();
Tdeserialize(Class clazz, InputStream in)
deserialize
ObjectInputStream objectIn = null;
try {
    objectIn = new ObjectInputStream(in);
    return clazz.cast(objectIn.readObject());
} finally {
    if (objectIn != null) {
        try {
            objectIn.close();
...
Tdeserialize(Class type, @Nullable byte[] objectBytes)
Turns a byte array into an object.
checkNotNull(type);
if (objectBytes == null) {
    return null;
try {
    return type.cast(new ObjectInputStream(new ByteArrayInputStream(objectBytes)).readObject());
} catch (ClassNotFoundException | IOException e) {
    throw new IllegalArgumentException("Unable to deserialize: objectBytes=" + base16().encode(objectBytes),
...