edu.stanford.nlp.io
Class IOUtils

java.lang.Object
  extended by edu.stanford.nlp.io.IOUtils

public class IOUtils
extends Object

Helper Class for storing serialized objects to disk.

Author:
Kayur Patel, Teg Grenager

Method Summary
static Object readObjectFromFile(File file)
          Read an object from a stored file.
static Object readObjectFromFile(String filename)
          Read an object from a stored file.
static Object readObjectFromFileNoExceptions(File file)
          Read an object from a stored file without throwing exceptions.
static File writeObjectToFile(Serializable o, String filename)
          Write object to a file with the specified name.
static File writeObjectToFileNoExceptions(Serializable o, String filename)
          Write object to a file with the specified name.
static File writeObjectToTempFile(Serializable o, String filename)
          Write object to temp file which is destroyed when the program exits.
static File writeObjectToTempFileNoExceptions(Serializable o, String filename)
          Write object to a temp file and ignore exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeObjectToFile

public static File writeObjectToFile(Serializable o,
                                     String filename)
                              throws IOException
Write object to a file with the specified name.

Parameters:
o - object to be written to file
filename - name of the temp file
Returns:
File containing the object
Throws:
IOException

writeObjectToFileNoExceptions

public static File writeObjectToFileNoExceptions(Serializable o,
                                                 String filename)
Write object to a file with the specified name.

Parameters:
o - object to be written to file
filename - name of the temp file
Returns:
File containing the object, or null if an exception was caught

writeObjectToTempFile

public static File writeObjectToTempFile(Serializable o,
                                         String filename)
                                  throws IOException
Write object to temp file which is destroyed when the program exits.

Parameters:
o - object to be written to file
filename - name of the temp file
Returns:
File containing the object
Throws:
IOException

writeObjectToTempFileNoExceptions

public static File writeObjectToTempFileNoExceptions(Serializable o,
                                                     String filename)
Write object to a temp file and ignore exceptions.

Parameters:
o - object to be written to file
filename - name of the temp file
Returns:
File containing the object

readObjectFromFile

public static Object readObjectFromFile(File file)
                                 throws IOException,
                                        ClassNotFoundException
Read an object from a stored file.

Parameters:
file - the file pointing to the object to be retrived
Returns:
the object read from the file.
Throws:
IOException
ClassNotFoundException

readObjectFromFile

public static Object readObjectFromFile(String filename)
                                 throws IOException,
                                        ClassNotFoundException
Read an object from a stored file.

Parameters:
filename - The filename of the object to be retrived
Returns:
The object read from the file.
Throws:
IOException
ClassNotFoundException

readObjectFromFileNoExceptions

public static Object readObjectFromFileNoExceptions(File file)
Read an object from a stored file without throwing exceptions.

Parameters:
file - the file pointing to the object to be retrived
Returns:
the object read from the file, or null if an exception occurred.


Stanford NLP Group