com.vividsolutions.jump.util
Class FileUtil

java.lang.Object
  extended by com.vividsolutions.jump.util.FileUtil

public class FileUtil
extends java.lang.Object

File-related utility functions.


Constructor Summary
FileUtil()
           
 
Method Summary
static java.io.File addExtensionIfNone(java.io.File file, java.lang.String extension)
           
static java.util.Collection<java.io.File> findFilesRecursively(java.io.File directory)
          Provides a collection of all the files in a directory.
static java.util.List getContents(java.io.InputStream inputStream)
           
static java.util.List getContents(java.lang.String textFileName)
          Reads a text file.
static java.lang.String getExtension(java.io.File f)
           
static void setContents(java.lang.String textFileName, java.util.List lines)
          Saves the List of Strings to a file with the given filename.
static void setContents(java.lang.String textFileName, java.lang.String contents)
          Saves the String to a file with the given filename.
static java.net.URL[] toURLs(java.io.File[] files)
           
static void zip(java.util.Collection files, java.io.File zipFile)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

getContents

public static java.util.List getContents(java.lang.String textFileName)
                                  throws java.io.FileNotFoundException,
                                         java.io.IOException
Reads a text file.

Parameters:
textFileName - the pathname of the file to open
Returns:
the lines of the text file
Throws:
java.io.FileNotFoundException - if the text file is not found
java.io.IOException - if the file is not found or another I/O error occurs

setContents

public static void setContents(java.lang.String textFileName,
                               java.lang.String contents)
                        throws java.io.IOException
Saves the String to a file with the given filename.

Parameters:
textFileName - the pathname of the file to create (or overwrite)
contents - the data to save
Throws:
java.io.IOException - if an I/O error occurs.

getContents

public static java.util.List getContents(java.io.InputStream inputStream)
                                  throws java.io.IOException
Throws:
java.io.IOException

setContents

public static void setContents(java.lang.String textFileName,
                               java.util.List lines)
                        throws java.io.IOException
Saves the List of Strings to a file with the given filename.

Parameters:
textFileName - the pathname of the file to create (or overwrite)
lines - the Strings to save as lines in the file
Throws:
java.io.IOException - if an I/O error occurs.

zip

public static void zip(java.util.Collection files,
                       java.io.File zipFile)
                throws java.io.IOException
Throws:
java.io.IOException

toURLs

public static java.net.URL[] toURLs(java.io.File[] files)

getExtension

public static java.lang.String getExtension(java.io.File f)

findFilesRecursively

public static java.util.Collection<java.io.File> findFilesRecursively(java.io.File directory)
Provides a collection of all the files in a directory.

Parameters:
directory -
Returns:

addExtensionIfNone

public static java.io.File addExtensionIfNone(java.io.File file,
                                              java.lang.String extension)