Code example for ObjectInputStream

Methods: close, readObject

0
    } 
 
    public static Object loadObject(File fileName) throws IOException, ClassNotFoundException {
        FileInputStream fileIn = new FileInputStream(fileName);
        BufferedInputStream buffdIn = new BufferedInputStream(fileIn, 32 * 1024);
        ObjectInputStream objectIn = new ObjectInputStream(buffdIn);
 
        Object object = objectIn.readObject();
 
        objectIn.close();
        buffdIn.close();
        fileIn.close();
 
        return object;
    } 
 
    public static int copyStreamToStream(InputStream in, OutputStream out) throws IOException {
        return copyStreamToStream(in, out, 1024);
    } 
 
    public static int copyStreamToStream(InputStream in, OutputStream out, int bufferSize) throws IOException {