Search in sources :

Example 36 with ObjectInputStream

use of java.io.ObjectInputStream in project Synthese_2BIN by TheYoungSensei.

the class ListeTrajets method deserialize.

@SuppressWarnings("unchecked")
public static boolean deserialize(String nomFichier) throws IOException, ClassNotFoundException {
    checkString(nomFichier);
    Path p = FileSystems.getDefault().getPath(nomFichier);
    if (Files.exists(p) && !Files.isReadable(p))
        return false;
    try (InputStream in = Files.newInputStream(p);
        ObjectInputStream o = new ObjectInputStream(in)) {
        Assembly.getListeTrajets().trajets = (SortedSet<Trajet>) o.readObject();
    }
    return true;
}
Also used : Path(java.nio.file.Path) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 37 with ObjectInputStream

use of java.io.ObjectInputStream in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class DataTag method load.

private DataTag load() {
    try {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
        DataTag obj = (DataTag) in.readObject();
        ints = obj.ints;
        strings = obj.strings;
        booleans = obj.booleans;
        bytes = obj.bytes;
        floats = obj.floats;
        shorts = obj.shorts;
        doubles = obj.doubles;
        longs = obj.longs;
        tags = obj.tags;
        objs = obj.objs;
        intArrays = obj.intArrays;
        stringArrays = obj.stringArrays;
        booleanArrays = obj.booleanArrays;
        byteArrays = obj.byteArrays;
        floatArrays = obj.floatArrays;
        shortArrays = obj.shortArrays;
        doubleArrays = obj.doubleArrays;
        longArrays = obj.longArrays;
        objArrays = obj.objArrays;
        in.close();
    } catch (Exception i) {
        if (!i.getClass().equals(EOFException.class)) {
            System.err.println("Exception: " + i.getClass().getName());
            i.printStackTrace();
        }
    }
    return this;
}
Also used : FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) EOFException(java.io.EOFException) ObjectInputStream(java.io.ObjectInputStream)

Example 38 with ObjectInputStream

use of java.io.ObjectInputStream in project voltdb by VoltDB.

the class InOutUtil method deserialize.

/**
     * Deserializes the specified byte array to an
     * <CODE>Object</CODE> instance.
     *
     * @return the Object resulting from deserializing the specified array of bytes
     * @param ba the byte array to deserialize to an Object
     */
public static Serializable deserialize(byte[] ba) throws IOException, ClassNotFoundException {
    HsqlByteArrayInputStream bi = new HsqlByteArrayInputStream(ba);
    ObjectInputStream is = new ObjectInputStream(bi);
    return (Serializable) is.readObject();
}
Also used : Serializable(java.io.Serializable) ObjectInputStream(java.io.ObjectInputStream)

Example 39 with ObjectInputStream

use of java.io.ObjectInputStream in project android_frameworks_base by ResurrectionRemix.

the class PrintPsTree method main.

public static void main(String[] args) throws IOException, ClassNotFoundException {
    if (args.length != 1) {
        System.err.println("Usage: PrintCsv [compiled log file]");
        System.exit(0);
    }
    FileInputStream fin = new FileInputStream(args[0]);
    ObjectInputStream oin = new ObjectInputStream(new BufferedInputStream(fin));
    Root root = (Root) oin.readObject();
    for (Proc proc : root.processes.values()) {
        if (proc.parent == null) {
            proc.print();
        }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 40 with ObjectInputStream

use of java.io.ObjectInputStream in project android_frameworks_base by ResurrectionRemix.

the class Root method fromFile.

/**
     * Reads Root from a file.
     */
static Root fromFile(String fileName) throws IOException, ClassNotFoundException {
    FileInputStream fin = new FileInputStream(fileName);
    ObjectInputStream oin = new ObjectInputStream(new BufferedInputStream(fin));
    Root root = (Root) oin.readObject();
    oin.close();
    return root;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

ObjectInputStream (java.io.ObjectInputStream)2159 ByteArrayInputStream (java.io.ByteArrayInputStream)1406 ObjectOutputStream (java.io.ObjectOutputStream)970 ByteArrayOutputStream (java.io.ByteArrayOutputStream)807 IOException (java.io.IOException)752 Test (org.junit.Test)458 FileInputStream (java.io.FileInputStream)339 File (java.io.File)197 InputStream (java.io.InputStream)157 ArrayList (java.util.ArrayList)90 BufferedInputStream (java.io.BufferedInputStream)84 Serializable (java.io.Serializable)66 FileNotFoundException (java.io.FileNotFoundException)64 FileOutputStream (java.io.FileOutputStream)63 HashMap (java.util.HashMap)63 Socket (java.net.Socket)49 Map (java.util.Map)48 ObjectInput (java.io.ObjectInput)45 GZIPInputStream (java.util.zip.GZIPInputStream)44 List (java.util.List)37