Java Utililty Methods ObjectOutputStream Write

List of utility methods to do ObjectOutputStream Write

Description

The list of methods to do ObjectOutputStream Write are organized into topic(s).

Method

TloadData(Class expectedClass, String filename)
load Data
T o = null;
try {
    FileInputStream fi = new FileInputStream(filename);
    ObjectInputStream oi = new ObjectInputStream(fi);
    o = expectedClass.cast(oi.readObject());
    oi.close();
    fi.close();
} catch (Exception e) {
...
HashMaploadData(HashMap data, String filename)
load Data
try {
    data = (HashMap) readObject(filename);
} catch (IOException e) {
    e.printStackTrace();
} catch (ClassNotFoundException e) {
    e.printStackTrace();
return data;
...
ObjectloadGZipObject(File file)
load G Zip Object
Object obj = null;
FileInputStream fis = null;
GZIPInputStream gis = null;
ObjectInputStream ois = null;
try {
    fis = new FileInputStream(file);
    gis = new GZIPInputStream(fis);
    ois = new ObjectInputStream(gis);
...
voidLoadMatFromFile(double[] mat, String filename)
Load Mat From File
try {
    java.io.FileInputStream fis = new java.io.FileInputStream(filename);
    java.io.ObjectInputStream inStream = new java.io.ObjectInputStream(fis);
    for (int i = 0; i < mat.length; i++)
        mat[i] = inStream.readDouble();
    inStream.close();
    inStream.close();
} catch (IOException e) {
...
ObjectloadObj(String file)
load Obj
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
Object qa = ois.readObject();
ois.close();
return qa;
SerializableloadSerializableFile(File file)
load Serializable File
Serializable result = null;
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
result = (Serializable) ois.readObject();
ois.close();
return result;
SerializableloadSerialized(File file)
load Serialized
try {
    return loadSerialized(new FileInputStream(file));
} catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("can't read serialized object from " + file + ": " + e);
ObjectloadSerializedObject(String fileName)
load Serialized Object
Object object = null;
try {
    InputStream file = new FileInputStream(fileName);
    InputStream buffer = new BufferedInputStream(file);
    ObjectInput input = new ObjectInputStream(buffer);
    try {
        object = input.readObject();
    } finally {
...
ObjectloadSerializedObjectWithExceptions(String fileName)
load Serialized Object With Exceptions
InputStream file = new FileInputStream(fileName);
InputStream buffer = new BufferedInputStream(file);
ObjectInput input = new ObjectInputStream(buffer);
Object object = input.readObject();
input.close();
return object;
Map>loadTrace(File file)
Loads a trace from the given file.
Map<String, Map<Integer, Integer>> classMap = new HashMap<String, Map<Integer, Integer>>();
ObjectInputStream ois;
try {
    ois = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))));
    int numClasses = ois.readInt();
    for (int i = 0; i < numClasses; i++) {
        String className = ois.readUTF();
        int numLines = ois.readInt();
...