edu.stanford.nlp.io
Class FileSystem

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

public final class FileSystem
extends Object

Provides various filesystem operations common to scripting languages such as Perl and Python but not present (currently) in the Java standard libraries.

Author:
Spence Green

Method Summary
static void copyFile(File sourceFile, File destFile)
          Copies a file.
static boolean deleteDir(File dir)
          Recursively deletes a directory, including all files and sub-directories.
static boolean existsAndNonEmpty(File file)
          Returns whether a file object both exists and has contents (i.e.
static void gzipFile(File uncompressedFileName, File compressedFileName)
          Similar to the unix gzip command, only it does not delete the file after compressing it.
static void main(String[] args)
          Unit test code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyFile

public static void copyFile(File sourceFile,
                            File destFile)
                     throws IOException
Copies a file. The ordering of the parameters corresponds to the Unix cp command.

Parameters:
sourceFile - The file to copy.
destFile - The path to copy to which the file should be copied.
Throws:
IOException

gzipFile

public static void gzipFile(File uncompressedFileName,
                            File compressedFileName)
                     throws IOException
Similar to the unix gzip command, only it does not delete the file after compressing it.

Parameters:
uncompressedFileName - The file to gzip
compressedFileName - The file name for the compressed file
Throws:
IOException

deleteDir

public static boolean deleteDir(File dir)
Recursively deletes a directory, including all files and sub-directories.

Parameters:
dir - The directory to delete
Returns:
true on success; false, otherwise.

existsAndNonEmpty

public static boolean existsAndNonEmpty(File file)
Returns whether a file object both exists and has contents (i.e. the size of the file is greater than 0)

Parameters:
file -
Returns:
true if the file exists and is non-empty

main

public static void main(String[] args)
Unit test code



Stanford NLP Group