edu.illinois.cs.cogcomp.lbj.coref.util.io
Class myIO

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.util.io.myIO

public class myIO
extends java.lang.Object

Author:
Eric

Constructor Summary
myIO()
           
 
Method Summary
 java.lang.String findFile(java.lang.String filename)
          Finds a file that is in the classpath.
static java.lang.String readAll(java.io.File f)
          Reads all the contents of the file.
static java.lang.String readAll(java.io.InputStream in)
          Reads all the contents of the file.
 java.lang.String readAll(java.lang.String filename)
          Reads all the contents of the file.
static java.lang.String readAll(java.net.URL url)
           
static java.util.List<java.lang.String> readLines(java.io.InputStream in)
           
 java.util.List<java.lang.String> readLines(java.lang.String filename)
          Read the lines from the file.
static java.util.List<java.lang.Object> readList(java.lang.String filename)
           
static void writeLines(java.lang.String filename, java.util.List<java.lang.String> lines)
           
static void writeList(java.lang.String filename, java.util.List<java.lang.Object> objects)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

myIO

public myIO()
Method Detail

readAll

public static java.lang.String readAll(java.net.URL url)

readAll

public java.lang.String readAll(java.lang.String filename)
Reads all the contents of the file. Assumes system-default character encoding. This method is not static because getResource does not find the resources when used in a static context.

Parameters:
filename - The name of a file, relative to the classpath.
Returns:
The contents of the file, or null on exception.

readAll

public static java.lang.String readAll(java.io.File f)
Reads all the contents of the file. Assumes system-default character encoding.

Parameters:
f - a File
Returns:
The contents of the file, or null on exception.

readAll

public static java.lang.String readAll(java.io.InputStream in)
Reads all the contents of the file. Assumes system-default character encoding. Does not close stream.

Parameters:
in - a stream view of the data.
Returns:
The contents of the file, or null on exception.

writeLines

public static void writeLines(java.lang.String filename,
                              java.util.List<java.lang.String> lines)
                       throws java.io.IOException
Throws:
java.io.IOException

writeList

public static void writeList(java.lang.String filename,
                             java.util.List<java.lang.Object> objects)
                      throws java.io.IOException
Parameters:
filename -
objects - must be serializable
Throws:
java.io.IOException

readList

public static java.util.List<java.lang.Object> readList(java.lang.String filename)
                                                 throws java.io.IOException,
                                                        java.lang.ClassNotFoundException
Parameters:
filename - containing Serialized List of objects.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readLines

public java.util.List<java.lang.String> readLines(java.lang.String filename)
Read the lines from the file. This method is not static because getResource does not work in a static context in an applet.

Parameters:
filename - relative to classpath.
Returns:
List of strings NOT containing eol characters.

readLines

public static java.util.List<java.lang.String> readLines(java.io.InputStream in)

findFile

public java.lang.String findFile(java.lang.String filename)
                          throws java.io.FileNotFoundException
Finds a file that is in the classpath.

Parameters:
filename - The name of the file, relative to a directory in the classpath.
Throws:
java.io.FileNotFoundException