edu.berkeley.nlp.lm.io
Class IOUtils
java.lang.Object
edu.berkeley.nlp.lm.io.IOUtils
public class IOUtils
- extends Object
Some IO utility functions. Naming convention: "Hard" means that the function
throws a RuntimeException upon failure, "Easy" means it returns null.
- Author:
- adampauls, Percy Liang
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IOUtils
public IOUtils()
openIn
public static BufferedReader openIn(String path)
throws IOException
- Throws:
IOException
openIn
public static BufferedReader openIn(File path)
throws IOException
- Throws:
IOException
openInHard
public static BufferedReader openInHard(String path)
openInHard
public static BufferedReader openInHard(File path)
openOut
public static PrintWriter openOut(String path)
throws IOException
- Throws:
IOException
openOut
public static PrintWriter openOut(File path)
throws IOException
- Throws:
IOException
openOutEasy
public static PrintWriter openOutEasy(String path)
openOutEasy
public static PrintWriter openOutEasy(File path)
openOutHard
public static PrintWriter openOutHard(String path)
openOutHard
public static PrintWriter openOutHard(File path)
openObjIn
public static ObjectInputStream openObjIn(String path)
throws IOException
- Throws:
IOException
openObjIn
public static ObjectInputStream openObjIn(File path)
throws IOException
- Throws:
IOException
openObjOut
public static ObjectOutputStream openObjOut(String path)
throws IOException
- Throws:
IOException
openObjOut
public static ObjectOutputStream openObjOut(File path)
throws IOException
- Throws:
IOException
readObjFile
public static Object readObjFile(String path)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
readObjFile
public static Object readObjFile(File path)
throws IOException,
ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
readObjFileEasy
public static Object readObjFileEasy(String path)
readObjFileEasy
public static Object readObjFileEasy(File path)
readObjFileHard
public static Object readObjFileHard(String path)
readObjFileHard
public static Object readObjFileHard(File path)
writeObjFile
public static void writeObjFile(File path,
Object obj)
throws IOException
- Throws:
IOException
writeObjFileEasy
public static boolean writeObjFileEasy(File path,
Object obj)
writeObjFileHard
public static void writeObjFileHard(String path,
Object obj)
writeObjFileHard
public static void writeObjFileHard(File path,
Object obj)
closeEasy
public static boolean closeEasy(BufferedReader in)
copy
public static int copy(InputStream in,
OutputStream out)
throws IOException
- Throws:
IOException
copy
public static int copy(Reader in,
Writer out)
throws IOException
- Throws:
IOException
lineIterator
public static Iterator<String> lineIterator(String path)
throws IOException
- Throws:
IOException
lineIterator
public static Iterator<String> lineIterator(BufferedReader reader)
- Parameters:
reader
-
- Returns:
readLines
public static List<String> readLines(BufferedReader in)
throws IOException
- Throws:
IOException
readLinesEasy
public static List<String> readLinesEasy(String path)
readLinesHard
public static List<String> readLinesHard(String path)
readLine
public static String readLine(String path)
throws IOException
- Throws:
IOException
readLineEasy
public static String readLineEasy(String path)
readLines
public static List<String> readLines(String path)
throws IOException
- Throws:
IOException
getCharEncoding
public static String getCharEncoding()
setCharEncoding
public static void setCharEncoding(String charEncoding)
getReader
public static BufferedReader getReader(InputStream in)
throws IOException
- Throws:
IOException
getWriter
public static PrintWriter getWriter(OutputStream out)
throws IOException
- Throws:
IOException