|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.utilities.fileio.FileUtilities
public final class FileUtilities
This Class contains utilities for handling files.
| Constructor Summary | |
|---|---|
FileUtilities()
|
|
| Method Summary | |
|---|---|
static boolean |
cleanDirectory(java.io.File directory)
Recursively cleans a directory without deleting it. |
static boolean |
cleanDirectory(java.lang.String directoryName)
Clean a directory without deleting it. |
static boolean |
copy(java.io.File source,
java.io.File destination)
|
static void |
copyFromURL(java.lang.String sourceURL,
java.io.File destination)
|
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
Copy the data from the input stream to the output stream. |
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out,
byte[] buffer)
Copy the data from the input stream to the output stream, using the buffer. |
static boolean |
deleteDirectory(java.io.File directory)
Recursively deletes all files and subdirectories of directory and then deletes the directory. |
static boolean |
deleteDirectory(java.lang.String directoryName)
Recursively delete a directory. |
static boolean |
deleteFile(java.io.File file)
Deletes a file. |
static boolean |
deleteFile(java.lang.String filePath)
Deletes s file. |
static java.util.List |
findFiles(java.io.File directory)
Find File objects in the given directory and all subdirectories. |
static java.util.List |
findFiles(java.io.File directory,
java.io.FileFilter fileFilter)
Uses the given fileFilter to find File objects in the given directory and all subdirectories. |
static java.util.List |
findFiles(java.io.File directory,
java.lang.String pattern)
Find File objects in the given directory and all subdirectories that meet the specified pattern (e.g. |
static java.lang.String |
getExtension(java.io.File theFile)
Returns the extension part of the files name. |
static java.lang.String |
getExtension(java.lang.String filename)
Returns the extension from a string. |
static java.lang.String |
getFileName(java.lang.String filepath)
Return the filename from path. |
static java.lang.String |
getFileName(java.lang.String filepath,
char fileSeparatorChar)
Return the filename from path. |
static java.lang.String |
getPath(java.lang.String filepath)
Return the path from filename. |
static java.lang.String |
getPath(java.lang.String filepath,
char fileSeparatorChar)
Return the path from filename. |
static java.io.File |
getResourcePathAsFile(java.lang.String resourcePath)
Returns a File object for a resource path, if the resource path can be resolved to a file system path. |
static java.io.File |
getURLAsFile(java.lang.String urlString)
Creates a File from a file system path given as a URL. |
static java.lang.String |
javaFileName(java.lang.String filename)
Standardize a files name. |
static java.lang.String[] |
list(java.io.File dir)
Lists the directory listing. |
static void |
main(java.lang.String[] args)
main(): For testing and sandboxing. |
static java.io.File |
mkdirFromPath(java.lang.String directoryPath)
Creates a directory using the given path. |
static java.io.File |
mkdirFromURL(java.lang.String directoryURL)
Creates a directory using the given URL. |
static boolean |
move(java.io.File from,
java.io.File to)
Move a file from one location to another. |
static boolean |
move(java.io.File from,
java.io.File to,
boolean overwrite)
Move a file from one location to another. |
static byte[] |
readBytes(java.io.File theFile)
Reads the file into a byte[]. |
static byte[] |
readBytes(java.io.InputStream istream)
Reads the InputStream into a byte[]. |
static byte[] |
readBytes(java.io.InputStream istream,
boolean closeStream)
Reads the InputStream into a byte[] and optionally closes the InputStream. |
static java.lang.String |
readFileURLAsTextFile(java.lang.String urlString)
Reads the text file from a file system path given as a URL. |
static java.io.Serializable |
readObj(java.io.File theFile)
Reads a serialized Object from a File. |
static java.lang.String |
readPathAsTextFile(java.lang.String path)
Reads the text file from a file system path. |
static java.lang.String |
readText(java.io.File theFile)
Reads the file assuming that it is a text file. |
static void |
writeBytes(byte[] b,
java.io.File theFile)
Writes the contents of a byte-array to the File. |
static void |
writeObj(java.io.Serializable object,
java.io.File theFile)
Writes and Object to the file in serialized format. |
static void |
writeStream(java.io.InputStream istream,
java.io.File theFile)
Writes an InputStream to the File. |
static void |
writeText(java.lang.String text,
java.io.File theFile)
Writes a String to the File. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileUtilities()
| Method Detail |
|---|
public static void writeText(java.lang.String text,
java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static void writeBytes(byte[] b,
java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static void writeStream(java.io.InputStream istream,
java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static byte[] readBytes(java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static byte[] readBytes(java.io.InputStream istream)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static byte[] readBytes(java.io.InputStream istream,
boolean closeStream)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.lang.String readPathAsTextFile(java.lang.String path)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String readFileURLAsTextFile(java.lang.String urlString)
throws java.lang.Exception
java.lang.Exception
public static java.io.File getURLAsFile(java.lang.String urlString)
throws java.lang.Exception
java.lang.Exception
public static java.io.File getResourcePathAsFile(java.lang.String resourcePath)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String readText(java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static final void copyFromURL(java.lang.String sourceURL,
java.io.File destination)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static final boolean copy(java.io.File source,
java.io.File destination)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static void copyStream(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static void copyStream(java.io.InputStream in,
java.io.OutputStream out,
byte[] buffer)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static void writeObj(java.io.Serializable object,
java.io.File theFile)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.io.Serializable readObj(java.io.File theFile)
throws java.io.IOException,
java.lang.ClassNotFoundException,
java.lang.Exception
java.lang.ClassNotFoundException - if the class saved in this file is
not described somewhere in the CLASSPATH.
java.io.IOException
java.lang.Exception
public static boolean deleteFile(java.lang.String filePath)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean deleteFile(java.io.File file)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean deleteDirectory(java.lang.String directoryName)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean deleteDirectory(java.io.File directory)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean cleanDirectory(java.lang.String directoryName)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean cleanDirectory(java.io.File directory)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static boolean move(java.io.File from,
java.io.File to)
throws java.io.IOException,
java.lang.Exception
from - file which should be moved.to - desired destination of the file.
java.io.IOException - if an error occurs.
java.lang.Exception
public static boolean move(java.io.File from,
java.io.File to,
boolean overwrite)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.io.File mkdirFromPath(java.lang.String directoryPath)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.io.File mkdirFromURL(java.lang.String directoryURL)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.lang.String[] list(java.io.File dir)
throws java.io.IOException,
java.lang.Exception
java.io.IOException
java.lang.Exceptionpublic static java.lang.String getPath(java.lang.String filepath)
public static java.lang.String getPath(java.lang.String filepath,
char fileSeparatorChar)
public static java.lang.String getFileName(java.lang.String filepath)
public static java.lang.String getFileName(java.lang.String filepath,
char fileSeparatorChar)
public static java.lang.String getExtension(java.lang.String filename)
public static java.lang.String getExtension(java.io.File theFile)
public static java.lang.String javaFileName(java.lang.String filename)
public static java.util.List findFiles(java.io.File directory,
java.lang.String pattern)
throws java.lang.Exception
java.lang.Exception
public static java.util.List findFiles(java.io.File directory)
throws java.lang.Exception
java.lang.Exception
public static java.util.List findFiles(java.io.File directory,
java.io.FileFilter fileFilter)
throws java.lang.Exception
java.lang.Exceptionpublic static void main(java.lang.String[] args)
args - commandline arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||