edu.stanford.nlp.io
Class IOUtils

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

public class IOUtils
extends java.lang.Object

Helper Class for storing serialized objects to disk.

Author:
Kayur Patel, Teg Grenager

Field Summary
static java.lang.String eolChar
           
 
Method Summary
static java.io.File backupFile(java.io.File file)
           
static java.lang.String backupName(java.lang.String filename)
           
static void closeIgnoringExceptions(java.io.Closeable c)
          Provides an implementation of closing a file for use in a finally block so you can correctly close a file without even more exception handling stuff.
static java.io.File ensureDir(java.io.File tgtDir)
          Given a filepath, makes sure a directory exists there.
static java.io.BufferedReader getBufferedFileReader(java.lang.String filename)
           
static java.io.BufferedReader getBufferedFileReader(java.lang.String filename, java.lang.String encoding)
           
static java.io.InputStream getBZip2PipedInputStream(java.lang.String filename)
           
static java.io.OutputStream getBZip2PipedOutputStream(java.lang.String filename)
           
static java.lang.String getExtension(java.lang.String fileName)
           
static java.io.InputStream getFileInputStream(java.lang.String filename)
          Get a input file stream (automatically gunzip/bunzip2 depending on file extension)
static java.io.OutputStream getFileOutputStream(java.lang.String filename)
          Get a output file stream (automatically gzip/bzip2 depending on file extension)
static java.io.InputStream getInputStreamFromURLOrClasspathOrFileSystem(java.lang.String textFileOrUrl)
          Locates this file either using the given URL, or in the CLASSPATH, or in the file system The CLASSPATH takes priority over the file system! This stream is buffered and gzipped (if necessary)
static java.io.File getJNLPLocalScratch()
          A JavaNLP specific convenience routine for obtaining the current scratch directory for the machine you're currently running on.
static java.io.PrintWriter getPrintWriter(java.io.File textFile)
           
static java.io.PrintWriter getPrintWriter(java.lang.String filename)
           
static java.io.PrintWriter getPrintWriter(java.lang.String filename, java.lang.String encoding)
           
static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir)
          Iterate over all the files in the directory, recursively.
static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir, java.util.regex.Pattern pattern)
          Iterate over all the files in the directory, recursively.
static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir, java.lang.String ext)
          Iterate over all the files in the directory, recursively.
static int lineCount(java.io.File textFile)
           
static java.util.List<java.lang.String> linesFromFile(java.lang.String filename)
          Returns the contents of a file as a list of strings.
static java.util.List<java.lang.String> linesFromFile(java.lang.String filename, java.lang.String encoding)
          Returns the contents of a file as a list of strings.
static void main(java.lang.String[] args)
           
static java.io.InputStream openFile(java.io.File file)
          Quietly opens a File.
static java.util.Set<java.lang.String> readColumnSet(java.lang.String infile, int field)
          Read column as set
static java.util.List<java.util.Map<java.lang.String,java.lang.String>> readCSVWithHeader(java.lang.String path)
           
static java.util.List<java.util.Map<java.lang.String,java.lang.String>> readCSVWithHeader(java.lang.String path, char quoteChar, char escapeChar)
          Read in a CSV formatted file with a header row
static java.lang.Iterable<java.lang.String> readLines(java.io.File file)
          Returns an Iterable of the lines in the file.
static java.lang.Iterable<java.lang.String> readLines(java.io.File file, java.lang.Class<? extends java.io.InputStream> fileInputStreamWrapper)
          Returns an Iterable of the lines in the file, wrapping the generated FileInputStream with an instance of the supplied class.
static java.lang.Iterable<java.lang.String> readLines(java.lang.String path)
          Returns an Iterable of the lines in the file.
static java.util.Map<java.lang.String,java.lang.String> readMap(java.lang.String filename)
           
static
<C> java.util.List<C>
readObjectFromColumns(java.lang.Class objClass, java.lang.String filename, java.lang.String[] fieldNames, java.lang.String delimiter)
           
static
<T> T
readObjectFromFile(java.io.File file)
          Read an object from a stored file.
static
<T> T
readObjectFromFile(java.lang.String filename)
          Read an object from a stored file.
static
<T> T
readObjectFromFileNoExceptions(java.io.File file)
          Read an object from a stored file without throwing exceptions.
static
<T> T
readObjectFromObjectStream(java.io.ObjectInputStream ois)
           
static java.io.BufferedReader readReaderFromString(java.lang.String textFileOrUrl)
           
static java.io.BufferedReader readReaderFromString(java.lang.String textFileOrUrl, java.lang.String encoding)
          Open a BufferedReader to a file or URL specified by a String name.
static java.io.ObjectInputStream readStreamFromString(java.lang.String filenameOrUrl)
           
static boolean renameToBackupName(java.io.File file)
           
static java.lang.String slurpFile(java.io.File file)
          Returns all the text in the given File.
static java.lang.String slurpFile(java.io.File file, java.lang.String encoding)
          Returns all the text in the given File.
static java.lang.String slurpFile(java.lang.String filename)
          Returns all the text in the given file
static java.lang.String slurpFile(java.lang.String filename, java.lang.String encoding)
          Returns all the text in the given file with the given encoding.
static java.lang.String slurpFileNoExceptions(java.io.File file)
          Returns all the text in the given File.
static java.lang.String slurpFileNoExceptions(java.lang.String filename)
          Returns all the text in the given File.
static java.lang.String slurpFileNoExceptions(java.lang.String filename, java.lang.String encoding)
          Returns all the text in the given file with the given encoding.
static java.lang.String slurpGBFile(java.lang.String filename)
           
static java.lang.String slurpGBFileNoExceptions(java.lang.String filename)
           
static java.lang.String slurpGBURL(java.net.URL u)
          Returns all the text at the given URL.
static java.lang.String slurpGBURLNoExceptions(java.net.URL u)
          Returns all the text at the given URL.
static java.lang.String slurpGZippedFile(java.io.File file)
          Returns all the text in the given File.
static java.lang.String slurpGZippedFile(java.lang.String filename)
          Returns all the text in the given File.
static java.lang.String slurpReader(java.io.Reader reader)
          Returns all the text from the given Reader.
static java.lang.String slurpURL(java.lang.String path)
          Returns all the text at the given URL.
static java.lang.String slurpURL(java.net.URL u)
          Returns all the text at the given URL.
static java.lang.String slurpURL(java.net.URL u, java.lang.String encoding)
          Returns all the text at the given URL.
static java.lang.String slurpURLNoExceptions(java.lang.String path)
          Returns all the text at the given URL.
static java.lang.String slurpURLNoExceptions(java.net.URL u)
          Returns all the text at the given URL.
static java.lang.String slurpURLNoExceptions(java.net.URL u, java.lang.String encoding)
          Returns all the text at the given URL.
static java.lang.String stringFromFile(java.lang.String filename)
          Returns the contents of a file as a single string.
static java.lang.String stringFromFile(java.lang.String filename, java.lang.String encoding)
          Returns the contents of a file as a single string.
static java.io.File writeObjectToFile(java.lang.Object o, java.io.File file)
          Write an object to a specified File.
static java.io.File writeObjectToFile(java.lang.Object o, java.io.File file, boolean append)
          Write an object to a specified File.
static java.io.File writeObjectToFile(java.lang.Object o, java.lang.String filename)
          Write object to a file with the specified name.
static java.io.File writeObjectToFileNoExceptions(java.lang.Object o, java.lang.String filename)
          Write object to a file with the specified name.
static java.io.File writeObjectToTempFile(java.lang.Object o, java.lang.String filename)
          Write object to temp file which is destroyed when the program exits.
static java.io.File writeObjectToTempFileNoExceptions(java.lang.Object o, java.lang.String filename)
          Write object to a temp file and ignore exceptions.
static java.io.ObjectOutputStream writeStreamFromString(java.lang.String serializePath)
           
static void writeStreamToStream(java.io.InputStream input, java.io.OutputStream output)
          Send all bytes from the input stream to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eolChar

public static final java.lang.String eolChar
Method Detail

writeObjectToFile

public static java.io.File writeObjectToFile(java.lang.Object o,
                                             java.lang.String filename)
                                      throws java.io.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:
java.io.IOException - If can't write file.

writeObjectToFile

public static java.io.File writeObjectToFile(java.lang.Object o,
                                             java.io.File file)
                                      throws java.io.IOException
Write an object to a specified File.

Parameters:
o - object to be written to file
file - The temp File
Returns:
File containing the object
Throws:
java.io.IOException - If File cannot be written

writeObjectToFile

public static java.io.File writeObjectToFile(java.lang.Object o,
                                             java.io.File file,
                                             boolean append)
                                      throws java.io.IOException
Write an object to a specified File.

Parameters:
o - object to be written to file
file - The temp File
append - If true, append to this file instead of overwriting it
Returns:
File containing the object
Throws:
java.io.IOException - If File cannot be written

writeObjectToFileNoExceptions

public static java.io.File writeObjectToFileNoExceptions(java.lang.Object o,
                                                         java.lang.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 java.io.File writeObjectToTempFile(java.lang.Object o,
                                                 java.lang.String filename)
                                          throws java.io.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:
java.io.IOException - If file cannot be written

writeObjectToTempFileNoExceptions

public static java.io.File writeObjectToTempFileNoExceptions(java.lang.Object o,
                                                             java.lang.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 <T> T readObjectFromFile(java.io.File file)
                            throws java.io.IOException,
                                   java.lang.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:
java.io.IOException - If file cannot be read
java.lang.ClassNotFoundException - If reading serialized object fails

readObjectFromObjectStream

public static <T> T readObjectFromObjectStream(java.io.ObjectInputStream ois)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObjectFromFile

public static <T> T readObjectFromFile(java.lang.String filename)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Read an object from a stored file.

Parameters:
filename - The filename of the object to be retrieved
Returns:
The object read from the file.
Throws:
java.io.IOException - If file cannot be read
java.lang.ClassNotFoundException - If reading serialized object fails

readObjectFromFileNoExceptions

public static <T> T readObjectFromFileNoExceptions(java.io.File file)
Read an object from a stored file without throwing exceptions.

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

lineCount

public static int lineCount(java.io.File textFile)
                     throws java.io.IOException
Throws:
java.io.IOException

writeStreamFromString

public static java.io.ObjectOutputStream writeStreamFromString(java.lang.String serializePath)
                                                        throws java.io.IOException
Throws:
java.io.IOException

readStreamFromString

public static java.io.ObjectInputStream readStreamFromString(java.lang.String filenameOrUrl)
                                                      throws java.io.IOException
Throws:
java.io.IOException

getInputStreamFromURLOrClasspathOrFileSystem

public static java.io.InputStream getInputStreamFromURLOrClasspathOrFileSystem(java.lang.String textFileOrUrl)
                                                                        throws java.io.IOException
Locates this file either using the given URL, or in the CLASSPATH, or in the file system The CLASSPATH takes priority over the file system! This stream is buffered and gzipped (if necessary)

Parameters:
textFileOrUrl -
Returns:
An InputStream for loading a resource
Throws:
java.io.IOException

readReaderFromString

public static java.io.BufferedReader readReaderFromString(java.lang.String textFileOrUrl)
                                                   throws java.io.IOException
Throws:
java.io.IOException

readReaderFromString

public static java.io.BufferedReader readReaderFromString(java.lang.String textFileOrUrl,
                                                          java.lang.String encoding)
                                                   throws java.io.IOException
Open a BufferedReader to a file or URL specified by a String name. If the String starts with https?://, then it is interpreted as a URL, otherwise it is interpreted as a local file. If the String ends in .gz, it is interpreted as a gzipped file (and uncompressed), else it is interpreted as a regular text file in the given encoding.

Parameters:
textFileOrUrl - What to read from
encoding - CharSet encoding
Returns:
The BufferedReader
Throws:
java.io.IOException - If there is an I/O problem

readLines

public static java.lang.Iterable<java.lang.String> readLines(java.lang.String path)
Returns an Iterable of the lines in the file. The file reader will be closed when the iterator is exhausted. IO errors will throw an (unchecked) RuntimeIOException

Parameters:
path - The file whose lines are to be read.
Returns:
An Iterable containing the lines from the file.

readLines

public static java.lang.Iterable<java.lang.String> readLines(java.io.File file)
Returns an Iterable of the lines in the file. The file reader will be closed when the iterator is exhausted.

Parameters:
file - The file whose lines are to be read.
Returns:
An Iterable containing the lines from the file.

readLines

public static java.lang.Iterable<java.lang.String> readLines(java.io.File file,
                                                             java.lang.Class<? extends java.io.InputStream> fileInputStreamWrapper)
Returns an Iterable of the lines in the file, wrapping the generated FileInputStream with an instance of the supplied class. IO errors will throw an (unchecked) RuntimeIOException

Parameters:
file - The file whose lines are to be read.
fileInputStreamWrapper - The class to wrap the InputStream with, e.g. GZIPInputStream. Note that the class must have a constructor that accepts an InputStream.
Returns:
An Iterable containing the lines from the file.

openFile

public static java.io.InputStream openFile(java.io.File file)
                                    throws RuntimeIOException
Quietly opens a File. If the file ends with a ".gz" extension, automatically opens a GZIPInputStream to wrap the constructed FileInputStream.

Throws:
RuntimeIOException

closeIgnoringExceptions

public static void closeIgnoringExceptions(java.io.Closeable c)
Provides an implementation of closing a file for use in a finally block so you can correctly close a file without even more exception handling stuff. From a suggestion in a talk by Josh Bloch.

Parameters:
c - The IO resource to close (e.g., a Stream/Reader)

iterFilesRecursive

public static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir)
Iterate over all the files in the directory, recursively.

Parameters:
dir - The root directory.
Returns:
All files within the directory.

iterFilesRecursive

public static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir,
                                                                  java.lang.String ext)
Iterate over all the files in the directory, recursively.

Parameters:
dir - The root directory.
ext - A string that must be at the end of all files (e.g. ".txt")
Returns:
All files within the directory ending in the given extension.

iterFilesRecursive

public static java.lang.Iterable<java.io.File> iterFilesRecursive(java.io.File dir,
                                                                  java.util.regex.Pattern pattern)
Iterate over all the files in the directory, recursively.

Parameters:
dir - The root directory.
pattern - A regular expression that the file path must match. This uses Matcher.find(), so use ^ and $ to specify endpoints.
Returns:
All files within the directory.

slurpFile

public static java.lang.String slurpFile(java.io.File file)
                                  throws java.io.IOException
Returns all the text in the given File.

Throws:
java.io.IOException

slurpFile

public static java.lang.String slurpFile(java.io.File file,
                                         java.lang.String encoding)
                                  throws java.io.IOException
Returns all the text in the given File.

Parameters:
file - The file to read from
encoding - The character encoding to assume. This may be null, and the platform default character encoding is used.
Throws:
java.io.IOException

slurpGZippedFile

public static java.lang.String slurpGZippedFile(java.lang.String filename)
                                         throws java.io.IOException
Returns all the text in the given File.

Throws:
java.io.IOException

slurpGZippedFile

public static java.lang.String slurpGZippedFile(java.io.File file)
                                         throws java.io.IOException
Returns all the text in the given File.

Throws:
java.io.IOException

slurpGBFileNoExceptions

public static java.lang.String slurpGBFileNoExceptions(java.lang.String filename)

slurpFile

public static java.lang.String slurpFile(java.lang.String filename,
                                         java.lang.String encoding)
                                  throws java.io.IOException
Returns all the text in the given file with the given encoding.

Throws:
java.io.IOException

slurpFileNoExceptions

public static java.lang.String slurpFileNoExceptions(java.lang.String filename,
                                                     java.lang.String encoding)
Returns all the text in the given file with the given encoding. If the file cannot be read (non-existent, etc.), then and only then the method returns null.


slurpGBFile

public static java.lang.String slurpGBFile(java.lang.String filename)
                                    throws java.io.IOException
Throws:
java.io.IOException

slurpFile

public static java.lang.String slurpFile(java.lang.String filename)
                                  throws java.io.IOException
Returns all the text in the given file

Returns:
The text in the file.
Throws:
java.io.IOException

slurpGBURL

public static java.lang.String slurpGBURL(java.net.URL u)
                                   throws java.io.IOException
Returns all the text at the given URL.

Throws:
java.io.IOException

slurpGBURLNoExceptions

public static java.lang.String slurpGBURLNoExceptions(java.net.URL u)
Returns all the text at the given URL.


slurpURLNoExceptions

public static java.lang.String slurpURLNoExceptions(java.net.URL u,
                                                    java.lang.String encoding)
Returns all the text at the given URL.


slurpURL

public static java.lang.String slurpURL(java.net.URL u,
                                        java.lang.String encoding)
                                 throws java.io.IOException
Returns all the text at the given URL.

Throws:
java.io.IOException

slurpURL

public static java.lang.String slurpURL(java.net.URL u)
                                 throws java.io.IOException
Returns all the text at the given URL.

Throws:
java.io.IOException

slurpURLNoExceptions

public static java.lang.String slurpURLNoExceptions(java.net.URL u)
Returns all the text at the given URL.


slurpURL

public static java.lang.String slurpURL(java.lang.String path)
                                 throws java.lang.Exception
Returns all the text at the given URL.

Throws:
java.lang.Exception

slurpURLNoExceptions

public static java.lang.String slurpURLNoExceptions(java.lang.String path)
Returns all the text at the given URL. If the file cannot be read (non-existent, etc.), then and only then the method returns null.


slurpFileNoExceptions

public static java.lang.String slurpFileNoExceptions(java.io.File file)
Returns all the text in the given File.

Returns:
The text in the file. May be an empty string if the file is empty. If the file cannot be read (non-existent, etc.), then and only then the method returns null.

slurpFileNoExceptions

public static java.lang.String slurpFileNoExceptions(java.lang.String filename)
Returns all the text in the given File.

Returns:
The text in the file. May be an empty string if the file is empty. If the file cannot be read (non-existent, etc.), then and only then the method returns null.

slurpReader

public static java.lang.String slurpReader(java.io.Reader reader)
Returns all the text from the given Reader.

Returns:
The text in the file.

writeStreamToStream

public static void writeStreamToStream(java.io.InputStream input,
                                       java.io.OutputStream output)
                                throws java.io.IOException
Send all bytes from the input stream to the output stream.

Parameters:
input - The input bytes.
output - Where the bytes should be written.
Throws:
java.io.IOException

readCSVWithHeader

public static java.util.List<java.util.Map<java.lang.String,java.lang.String>> readCSVWithHeader(java.lang.String path,
                                                                                                 char quoteChar,
                                                                                                 char escapeChar)
                                                                                          throws java.io.IOException
Read in a CSV formatted file with a header row

Parameters:
path - - path to CSV file
quoteChar - - character for enclosing strings, defaults to "
escapeChar - - character for escaping quotes appearing in quoted strings; defaults to " (i.e. "" is used for " inside quotes, consistent with Excel)
Returns:
a list of maps representing the rows of the csv. The maps' keys are the header strings and their values are the row contents
Throws:
java.io.IOException

readCSVWithHeader

public static java.util.List<java.util.Map<java.lang.String,java.lang.String>> readCSVWithHeader(java.lang.String path)
                                                                                          throws java.io.IOException
Throws:
java.io.IOException

getFileInputStream

public static java.io.InputStream getFileInputStream(java.lang.String filename)
                                              throws java.io.IOException
Get a input file stream (automatically gunzip/bunzip2 depending on file extension)

Parameters:
filename - Name of file to open
Returns:
Input stream that can be used to read from the file
Throws:
java.io.IOException - if there are exceptions opening the file

getFileOutputStream

public static java.io.OutputStream getFileOutputStream(java.lang.String filename)
                                                throws java.io.IOException
Get a output file stream (automatically gzip/bzip2 depending on file extension)

Parameters:
filename - Name of file to open
Returns:
Output stream that can be used to write to the file
Throws:
java.io.IOException - if there are exceptions opening the file

getBufferedFileReader

public static java.io.BufferedReader getBufferedFileReader(java.lang.String filename)
                                                    throws java.io.IOException
Throws:
java.io.IOException

getBufferedFileReader

public static java.io.BufferedReader getBufferedFileReader(java.lang.String filename,
                                                           java.lang.String encoding)
                                                    throws java.io.IOException
Throws:
java.io.IOException

getPrintWriter

public static java.io.PrintWriter getPrintWriter(java.io.File textFile)
                                          throws java.io.IOException
Throws:
java.io.IOException

getPrintWriter

public static java.io.PrintWriter getPrintWriter(java.lang.String filename)
                                          throws java.io.IOException
Throws:
java.io.IOException

getPrintWriter

public static java.io.PrintWriter getPrintWriter(java.lang.String filename,
                                                 java.lang.String encoding)
                                          throws java.io.IOException
Throws:
java.io.IOException

getBZip2PipedInputStream

public static java.io.InputStream getBZip2PipedInputStream(java.lang.String filename)
                                                    throws java.io.IOException
Throws:
java.io.IOException

getBZip2PipedOutputStream

public static java.io.OutputStream getBZip2PipedOutputStream(java.lang.String filename)
                                                      throws java.io.IOException
Throws:
java.io.IOException

readColumnSet

public static java.util.Set<java.lang.String> readColumnSet(java.lang.String infile,
                                                            int field)
                                                     throws java.io.IOException
Read column as set

Parameters:
infile - - filename
field - index of field to read
Returns:
a set of the entries in column field
Throws:
java.io.IOException

readObjectFromColumns

public static <C> java.util.List<C> readObjectFromColumns(java.lang.Class objClass,
                                                          java.lang.String filename,
                                                          java.lang.String[] fieldNames,
                                                          java.lang.String delimiter)
                                               throws java.io.IOException,
                                                      java.lang.InstantiationException,
                                                      java.lang.IllegalAccessException,
                                                      java.lang.NoSuchFieldException,
                                                      java.lang.NoSuchMethodException,
                                                      java.lang.reflect.InvocationTargetException
Throws:
java.io.IOException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.NoSuchFieldException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException

readMap

public static java.util.Map<java.lang.String,java.lang.String> readMap(java.lang.String filename)
                                                                throws java.io.IOException
Throws:
java.io.IOException

stringFromFile

public static java.lang.String stringFromFile(java.lang.String filename)
Returns the contents of a file as a single string. The string may be empty, if the file is empty. If there is an IOException, it is caught and null is returned.


stringFromFile

public static java.lang.String stringFromFile(java.lang.String filename,
                                              java.lang.String encoding)
Returns the contents of a file as a single string. The string may be empty, if the file is empty. If there is an IOException, it is caught and null is returned. Encoding can also be specified.


linesFromFile

public static java.util.List<java.lang.String> linesFromFile(java.lang.String filename)
Returns the contents of a file as a list of strings. The list may be empty, if the file is empty. If there is an IOException, it is caught and null is returned.


linesFromFile

public static java.util.List<java.lang.String> linesFromFile(java.lang.String filename,
                                                             java.lang.String encoding)
Returns the contents of a file as a list of strings. The list may be empty, if the file is empty. If there is an IOException, it is caught and null is returned. Encoding can also be specified


backupName

public static java.lang.String backupName(java.lang.String filename)

backupFile

public static java.io.File backupFile(java.io.File file)

renameToBackupName

public static boolean renameToBackupName(java.io.File file)

getJNLPLocalScratch

public static java.io.File getJNLPLocalScratch()
A JavaNLP specific convenience routine for obtaining the current scratch directory for the machine you're currently running on.


ensureDir

public static java.io.File ensureDir(java.io.File tgtDir)
                              throws java.lang.Exception
Given a filepath, makes sure a directory exists there. If not, creates and returns it. Same as ENSURE-DIRECTORY in CL.

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)

getExtension

public static java.lang.String getExtension(java.lang.String fileName)


Stanford NLP Group