|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.igfay.util.FileUtility
Helper methods for working with File objects
Field Summary | |
protected static Logger |
log
|
Constructor Summary | |
FileUtility()
|
Method Summary | |
static void |
closeStreams(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Close the provided input and output streams. |
static java.lang.String |
contentsOfFile(java.io.File file)
Return the contents of the provided File as a String |
static java.lang.String |
contentsOfFile(java.lang.String fileName)
Return the contents of the provided file name as a String |
static void |
copy(java.io.File inFile,
java.io.File outFile)
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
|
static boolean |
ensureFilePathExists(java.io.File file)
Ensure that the provided file exists. |
static boolean |
ensureFilePathExists(java.lang.String fileString)
Ensure that the provided file name exists. |
static boolean |
ensurePathExists(java.io.File file)
Ensure that the path to the provided file exists. |
static boolean |
ensurePathExists(java.lang.String fileString)
Ensure that the path to the provided file name exists. |
static java.io.File |
findExistingFile(java.lang.String fileName)
Return a File for an existing file. |
static java.io.BufferedReader |
getBufferedReaderFromFile(java.io.File file)
Return the provided File as a BufferedReader |
static java.io.BufferedReader |
getBufferedReaderFromFile(java.lang.String fileString)
Return the provided file name as a BufferedReader |
static java.lang.String |
getExceptionMessage(java.lang.Exception e,
java.io.File file)
|
static java.lang.String |
getLogFileName()
Return the name of the log file. |
static void |
iteratorToFile(java.util.Iterator it,
java.lang.String fileName)
Write the provided iterator to a file of the provided file name. |
static java.io.PrintStream |
newPrintStreamOnFileNamed(java.io.File directory,
java.lang.String name)
|
static java.io.PrintWriter |
newPrintWriterOnFileNamed(java.io.File directory,
java.lang.String name)
Create and return a PrintWriter for the provided directory and file name. |
static java.lang.Object |
readObjectFromBufferedFileObject(java.io.File file)
Convert the provided File into a BufferedInputStream. |
static java.lang.Object |
readObjectFromFile(java.io.File file)
Read the provded file and return the contents as an Object. |
static java.lang.Object |
readObjectFromFile(java.io.File directory,
java.lang.String name)
Read the contents of the provided file name residing in the provided directory. |
static java.lang.Object |
readObjectFromFileWithPath(java.lang.String fileWithPath)
Read the contents of the provided file name residing in the provided directory. |
static void |
redirectStandardOutput()
Redirect standard output to the log file. |
static void |
redirectStandardOutput(java.io.File file)
Redirect standard output to the provided File. |
static void |
redirectStandardOutput(java.lang.String fileName)
Redirect standard output to the provided file name. |
static java.lang.String |
streamToString(java.io.InputStream inputStream)
Return the provided InputStream as a String |
static java.lang.String |
stringFromFile(java.io.File file)
Return the contents of the provided file as a String. |
static java.lang.String |
stringFromFile(java.lang.String fileName)
Return the contents of the provided file name as a String. |
static void |
stringToFile(java.lang.String string,
java.io.File file)
Convert the provided String into the provided File. |
static void |
stringToFile(java.lang.String string,
java.lang.String fileString)
Convert the provided String into a File of the provided file name. |
static void |
stringToFileOutputStream(java.lang.String string,
java.io.FileOutputStream fos)
Convert the provided String into the provided FileOutputStream. |
static void |
writeObjectToFile(java.lang.Object object,
java.io.File directory,
java.lang.String name)
Write the provided object to a file of the provided directory and file name. |
static void |
writeObjectToFileObject(java.lang.Object object,
java.io.File file)
Write the provided object to the provided File. |
static void |
writeObjectToFileWithPath(java.lang.Object object,
java.lang.String fileAndPath)
Write the provided object to the provided file name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static Logger log
Constructor Detail |
public FileUtility()
Method Detail |
public static java.lang.String contentsOfFile(java.io.File file)
file
-
public static java.lang.String contentsOfFile(java.lang.String fileName)
fileName
-
public static void copy(java.io.File inFile, java.io.File outFile) throws java.io.IOException
java.io.IOException
public static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static void closeStreams(java.io.InputStream inputStream, java.io.OutputStream outputStream)
inputStream
- outputStream
- public static boolean ensureFilePathExists(java.io.File file)
file
-
public static boolean ensurePathExists(java.io.File file)
file
-
public static boolean ensureFilePathExists(java.lang.String fileString)
fileString
-
public static boolean ensurePathExists(java.lang.String fileString)
fileString
-
public static java.io.PrintStream newPrintStreamOnFileNamed(java.io.File directory, java.lang.String name) throws java.io.IOException
java.io.IOException
public static java.io.PrintWriter newPrintWriterOnFileNamed(java.io.File directory, java.lang.String name) throws java.io.IOException
directory
- name
-
java.io.IOException
public static java.lang.Object readObjectFromBufferedFileObject(java.io.File file) throws java.io.IOException, java.lang.ClassNotFoundException
file
-
java.io.IOException
java.lang.ClassNotFoundException
public static java.lang.Object readObjectFromFile(java.io.File file) throws java.io.IOException, java.lang.ClassNotFoundException
file
- java.lang.String
java.io.IOException
- Description of Exception
java.lang.ClassNotFoundException
- Description of Exceptionpublic static java.lang.Object readObjectFromFile(java.io.File directory, java.lang.String name) throws java.io.IOException, java.lang.ClassNotFoundException
directory
- name
-
java.io.IOException
java.lang.ClassNotFoundException
public static java.lang.Object readObjectFromFileWithPath(java.lang.String fileWithPath) throws java.io.IOException, java.lang.ClassNotFoundException
fileWithPath
-
java.io.IOException
java.lang.ClassNotFoundException
public static void redirectStandardOutput()
public static void redirectStandardOutput(java.io.File file)
file
- public static void redirectStandardOutput(java.lang.String fileName)
public static java.lang.String stringFromFile(java.io.File file)
file
-
public static java.lang.String stringFromFile(java.lang.String fileName)
public static void stringToFile(java.lang.String string, java.io.File file)
string
- file
- public static void stringToFile(java.lang.String string, java.lang.String fileString)
string
- public static void stringToFileOutputStream(java.lang.String string, java.io.FileOutputStream fos) throws java.io.IOException
string
- fos
-
java.io.IOException
public static void writeObjectToFile(java.lang.Object object, java.io.File directory, java.lang.String name) throws java.io.IOException
object
- directory
- name
-
java.io.IOException
public static void writeObjectToFileObject(java.lang.Object object, java.io.File file) throws java.io.IOException
object
- file
-
java.io.IOException
public static void writeObjectToFileWithPath(java.lang.Object object, java.lang.String fileAndPath) throws java.io.IOException
object
- fileAndPath
-
java.io.IOException
public static void iteratorToFile(java.util.Iterator it, java.lang.String fileName) throws java.io.IOException
it
- fileName
-
java.io.IOException
public static java.io.BufferedReader getBufferedReaderFromFile(java.io.File file) throws java.io.FileNotFoundException
file
-
java.io.FileNotFoundException
public static java.io.BufferedReader getBufferedReaderFromFile(java.lang.String fileString) throws java.io.FileNotFoundException
fileString
-
java.io.FileNotFoundException
public static java.lang.String getExceptionMessage(java.lang.Exception e, java.io.File file)
public static java.lang.String getLogFileName()
public static java.io.File findExistingFile(java.lang.String fileName)
fileName
-
public static java.lang.String streamToString(java.io.InputStream inputStream)
inputStream
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |