Java ObjectOutputStream Write loadSerialized(File file)

Here you can find the source of loadSerialized(File file)

Description

load Serialized

License

Open Source License

Declaration

static public Serializable loadSerialized(File file) throws IOException 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    static public Serializable loadSerialized(File file) throws IOException {
        try {/*from www . java2 s  .  co  m*/
            return loadSerialized(new FileInputStream(file));
            /*ObjectInputStream in =
               new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
               Object obj = in.readObject();
               in.close();
               return (Serializable)obj;
             */
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("can't read serialized object from " + file + ": " + e);
        }
    }

    public static Serializable loadSerialized(InputStream input) throws IOException {
        try {
            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(input));
            Object obj = in.readObject();
            in.close();
            return (Serializable) obj;
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("can't read serialized object from " + input + ": " + e);
        }
    }
}

Related

  1. loadData(HashMap data, String filename)
  2. loadGZipObject(File file)
  3. LoadMatFromFile(double[] mat, String filename)
  4. loadObj(String file)
  5. loadSerializableFile(File file)
  6. loadSerializedObject(String fileName)
  7. loadSerializedObjectWithExceptions(String fileName)
  8. loadTrace(File file)
  9. save(File f, T o)