Java Object Deserialize from File deserializeFromDisk(String filePath)

Here you can find the source of deserializeFromDisk(String filePath)

Description

Deserializes an object from disk.

License

Open Source License

Parameter

Parameter Description
filePath the file path

Exception

Parameter Description
Exception an exception

Return

an object. Clients have to cast the object to the expected type.

Declaration

public static Object deserializeFromDisk(String filePath)
        throws Exception 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2013/*www .j a  v a2  s  .c  om*/

 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universit?t Darmstadt
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl-3.0.txt
 ******************************************************************************/

import java.io.File;
import java.io.FileInputStream;

import java.io.ObjectInputStream;

public class Main {
    /**
     * Deserializes an object from disk.
     *
     * @param filePath the file path
     * @return an object. Clients have to cast the object to the expected type.
     * @throws Exception an exception
     */
    public static Object deserializeFromDisk(String filePath)
            throws Exception {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(
                new File(filePath)));

        return in.readObject();
    }
}

Related

  1. deserialize(String fName)
  2. deserialize(String fname)
  3. deserialize(String path)
  4. deserialize(String path)
  5. deserialize(String path)
  6. deserializeFromFile(File file)
  7. deserializeFromFile(File file)
  8. deserializeFromFile(String path)
  9. deserializeFromFile(String path)