org.knowceans.util
Class ObjectIo

java.lang.Object
  extended by org.knowceans.util.ObjectIo

public class ObjectIo
extends java.lang.Object

ObjectIo provides a simplified interface for object io to zip files. Open streams using open*Stream(filename), then write to / read from the returned Object*Stream and close the stream using close*Stream() or Object*Stream.close(). The close*Stream() methods are provided for symmetry with the open*Stream() methods, in order to improve code readability.

Author:
gregor

Constructor Summary
ObjectIo()
           
 
Method Summary
static void closeInputStream(java.io.ObjectInputStream dis)
          Close the input stream
static void closeOutputStream(java.io.ObjectOutputStream dos)
          Close the data output, which results in flushing the write buffer and closing the file.
static java.io.ObjectInputStream openInputStream(java.lang.String filename)
          Opens a data input stream with optional zip compression.
static java.io.ObjectOutputStream openOutputStream(java.lang.String filename)
          Opens an object output stream with optional zip compression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectIo

public ObjectIo()
Method Detail

openOutputStream

public static java.io.ObjectOutputStream openOutputStream(java.lang.String filename)
                                                   throws java.io.FileNotFoundException,
                                                          java.io.IOException
Opens an object output stream with optional zip compression. The returned DataOutputStream can be written to and must be closed using closeStream(ObjectOutputStream dos) or dos.close().

Parameters:
filename -
Returns:
Throws:
java.io.IOException
java.io.FileNotFoundException

closeOutputStream

public static void closeOutputStream(java.io.ObjectOutputStream dos)
                              throws java.io.IOException
Close the data output, which results in flushing the write buffer and closing the file.

Parameters:
dos -
Throws:
java.io.IOException

openInputStream

public static java.io.ObjectInputStream openInputStream(java.lang.String filename)
                                                 throws java.io.IOException
Opens a data input stream with optional zip compression. The returned ObjectInputStream can be read from and must be closed using closeStream(ObjectOutputStream dos) or dos.close().

Parameters:
filename -
Returns:
Throws:
java.io.IOException

closeInputStream

public static void closeInputStream(java.io.ObjectInputStream dis)
                             throws java.io.IOException
Close the input stream

Parameters:
dis -
Throws:
java.io.IOException