stomp.util
Class FileManager

java.lang.Object
  |
  +--stomp.util.FileManager

public class FileManager
extends java.lang.Object

provides utilities for reading and writing files to disk

Author:
Eric Lindauer

Constructor Summary
FileManager()
           
 
Method Summary
static void compile(java.util.Collection files)
          compiles all of the files in the list at one time
static void compile(java.lang.String file)
          execs and waits for a new Process, javac file
static void findFilesEndingWith(java.io.File root, java.io.File current, java.util.Collection resultsSoFar, java.lang.String ending)
          for more advanced searches...
static java.lang.String[] findFilesEndingWith(java.lang.String ending)
           
static java.lang.String getClassFileName(java.lang.String name)
           
static java.lang.String getDirectoryName(java.io.File file)
          returns the name of the directory that this is in / represents.
static java.lang.StringBuffer getFile(java.lang.String location)
           
static java.io.File getJavaRootFile()
           
static java.lang.String getPackageName(java.io.File theFile)
          returns a "." delimited description of the directory path from FileManager.JAVA_ROOT to the given file.
static java.util.Properties getProperties(java.lang.String propertyFileName)
          returns a Properties object that has been initialized to the contents of the given propertyFile, findable someplace on the CLASSPATH.
static java.lang.String getROOT()
           
static java.lang.StringBuffer readFile(java.io.File theFile)
           
static java.lang.StringBuffer readFile(java.lang.String location)
          reads in the given file and returns its contents in a StringBuffer
static java.lang.StringBuffer readFile(java.lang.String location, boolean useRoot)
          reads in the given file and returns its contents in a StringBuffer.
static void writeFile(java.lang.String location, java.lang.String contents)
           
static void writeFile(java.lang.String location, java.lang.String contents, boolean useRoot)
          writes the given StringBuffer to the given file location, overwriting anything that is already there.
static void writeFile(java.lang.String location, java.lang.String contents, boolean useRoot, boolean temp)
           
static void writeFile(java.lang.String location, java.lang.StringBuffer string)
          writes the given StringBuffer to given file location, regardless of whether or not there is something there already
static void writeTempFile(java.lang.String location, java.lang.String contents)
          writes the given information to a temporary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManager

public FileManager()
Method Detail

getJavaRootFile

public static java.io.File getJavaRootFile()

getROOT

public static java.lang.String getROOT()

getFile

public static java.lang.StringBuffer getFile(java.lang.String location)
                                      throws java.io.FileNotFoundException,
                                             java.io.IOException
java.io.FileNotFoundException
java.io.IOException

readFile

public static java.lang.StringBuffer readFile(java.lang.String location)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException
reads in the given file and returns its contents in a StringBuffer

java.io.FileNotFoundException
java.io.IOException

readFile

public static java.lang.StringBuffer readFile(java.lang.String location,
                                              boolean useRoot)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException
reads in the given file and returns its contents in a StringBuffer. if useRoot is true, the file will be prepended with the ROOT variable in this.

java.io.FileNotFoundException
java.io.IOException

readFile

public static java.lang.StringBuffer readFile(java.io.File theFile)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException
java.io.FileNotFoundException
java.io.IOException

writeFile

public static void writeFile(java.lang.String location,
                             java.lang.StringBuffer string)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
writes the given StringBuffer to given file location, regardless of whether or not there is something there already

java.io.FileNotFoundException
java.io.IOException

writeFile

public static void writeFile(java.lang.String location,
                             java.lang.String contents)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
java.io.FileNotFoundException
java.io.IOException
See Also:
( String location, StringBuffer string );

writeFile

public static void writeFile(java.lang.String location,
                             java.lang.String contents,
                             boolean useRoot)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
writes the given StringBuffer to the given file location, overwriting anything that is already there. if useRoot is true, prepends the root variable in this to the file location

java.io.FileNotFoundException
java.io.IOException

writeFile

public static void writeFile(java.lang.String location,
                             java.lang.String contents,
                             boolean useRoot,
                             boolean temp)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
java.io.FileNotFoundException
java.io.IOException

writeTempFile

public static void writeTempFile(java.lang.String location,
                                 java.lang.String contents)
                          throws java.io.FileNotFoundException,
                                 java.io.IOException
writes the given information to a temporary file. This file will disappear when the current JVM expires

java.io.FileNotFoundException
java.io.IOException

compile

public static void compile(java.lang.String file)
                    throws java.io.IOException,
                           java.lang.InterruptedException
execs and waits for a new Process, javac file

java.io.IOException
java.lang.InterruptedException

compile

public static void compile(java.util.Collection files)
                    throws java.io.IOException,
                           java.lang.InterruptedException
compiles all of the files in the list at one time

java.io.IOException
java.lang.InterruptedException

findFilesEndingWith

public static java.lang.String[] findFilesEndingWith(java.lang.String ending)

findFilesEndingWith

public static void findFilesEndingWith(java.io.File root,
                                       java.io.File current,
                                       java.util.Collection resultsSoFar,
                                       java.lang.String ending)
for more advanced searches... adds all files with the given ending, findable from the given current directory or below, into the given collection of results. The string added is the path from the given root to the found file.


getClassFileName

public static java.lang.String getClassFileName(java.lang.String name)

getDirectoryName

public static java.lang.String getDirectoryName(java.io.File file)
returns the name of the directory that this is in / represents.


getProperties

public static java.util.Properties getProperties(java.lang.String propertyFileName)
                                          throws java.io.IOException
returns a Properties object that has been initialized to the contents of the given propertyFile, findable someplace on the CLASSPATH.

java.io.IOException

getPackageName

public static java.lang.String getPackageName(java.io.File theFile)
returns a "." delimited description of the directory path from FileManager.JAVA_ROOT to the given file. If there is at least one directory between JAVA_ROOT and theFile, the returned String will end in a ".", otherwise, "" is returned. requires: theFile is in a subdirectory of JAVA_ROOT