|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.enterprise.util.io.FileUtils
public class FileUtils
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static void |
appendText(java.lang.String fileName,
java.lang.String line)
Appends the given line at the end of given text file. |
static void |
appendText(java.lang.String fileName,
java.lang.StringBuffer buffer)
|
static void |
copy(java.io.File fin,
java.io.File fout)
Copies a file. |
static void |
copy(java.io.InputStream in,
java.io.FileOutputStream out,
long size)
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream os,
long size)
|
static void |
copy(java.lang.String from,
java.lang.String to)
Copies a file. |
static void |
copyFile(java.io.File fin,
java.io.File fout)
This method is used to copy a given file to another file using the buffer sixe specified |
static void |
copyTree(java.io.File din,
java.io.File dout)
Copies the entire tree to a new location. |
static void |
copyWithoutClose(java.io.InputStream in,
java.io.FileOutputStream out,
long size)
|
static java.io.File |
createTempFile(java.io.File directory)
|
static boolean |
deleteFile(java.io.File f)
Delete a file. |
static java.io.File[] |
findFilesInDir(java.io.File dir,
java.lang.String regexp)
Find files matching the regular expression in the given directory |
static java.lang.String |
formatFileCollection(java.util.Collection<java.io.File> files)
Creates a String listing the absolute paths of files, separated by the platform's line separator. |
static java.util.Set |
getAllFilesAndDirectoriesUnder(java.io.File directory)
|
static java.util.Set |
getAllFilesUnder(java.io.File directory,
java.io.FilenameFilter filenameFilter)
Return a set of all the files (File objects) under the directory specified, with relative pathnames filtered with the filename filter (can be null for all files). |
static java.util.Set |
getAllFilesUnder(java.io.File directory,
java.io.FilenameFilter filenameFilter,
boolean relativize)
|
static java.io.File |
getDirectory(java.io.File f)
|
static java.lang.String |
getIllegalFilenameCharacters()
|
static java.io.File |
getManagedFile(java.lang.String file,
java.io.File dir)
If the path dir/file does not exist, look for it in the classpath. |
static boolean |
hasExtension(java.io.File f,
java.lang.String ext)
|
static boolean |
hasExtension(java.lang.String filename,
java.lang.String ext)
|
static boolean |
hasExtensionIgnoreCase(java.io.File f,
java.lang.String ext)
|
static boolean |
hasExtensionIgnoreCase(java.lang.String filename,
java.lang.String ext)
|
static boolean |
isFriendlyFilename(java.lang.String filename)
|
static boolean |
isJar(java.io.File f)
|
static boolean |
isJar(java.lang.String filename)
|
static boolean |
isLegalFilename(java.lang.String filename)
|
static boolean |
isZip(java.io.File f)
|
static boolean |
isZip(java.lang.String filename)
|
static void |
liquidate(java.io.File parent)
|
static java.io.File[] |
listAllFiles(java.io.File dirName,
java.lang.String ext)
Returns an array of abstract pathnames that matches with the given file extension. |
static java.io.File[] |
listFiles(java.io.File f)
|
static java.io.File[] |
listFiles(java.io.File f,
java.io.FileFilter ff)
|
static java.io.File[] |
listFiles(java.io.File f,
java.io.FilenameFilter fnf)
|
static java.lang.String |
makeForwardSlashes(java.lang.String inputStr)
Returns a String with uniform slashes such that all the occurances of '\\' are replaced with '/'. |
static java.lang.String |
makeFriendlyFilename(java.lang.String filename)
|
static java.lang.String |
makeFriendlyFilenameExtension(java.lang.String filename)
|
static java.lang.String |
makeFriendlyFilenameNoExtension(java.lang.String filename)
|
static java.lang.String |
makeLegalFilename(java.lang.String filename)
|
static java.lang.String |
makeLegalNoBlankFileName(java.lang.String filename)
|
static java.io.FileOutputStream |
openFileOutputStream(java.io.File out)
Opens a stream to the specified output file, retrying if necessary. |
static java.lang.String |
quoteString(java.lang.String s)
Given a string (typically a path), quote the string such that spaces are protected from interpretation by a Unix or Windows command shell. |
static java.lang.String |
readSmallFile(java.io.File file)
|
static java.lang.String |
readSmallFile(java.lang.String fileName)
A utility routine to read a text file efficiently and return the contents as a String. |
static java.io.File |
relativize(java.io.File parent,
java.io.File child)
Given a directory and a fully-qualified file somewhere under that directory, return the portion of the child that is relative to the parent. |
static boolean |
renameFile(java.io.File fromFile,
java.io.File toFile)
Rename, running gc on Windows if needed to try to force open streams to close. |
static java.lang.String |
revertFriendlyFilename(java.lang.String filename)
|
static java.lang.String |
revertFriendlyFilenameExtension(java.lang.String filename)
|
static java.io.File |
safeGetCanonicalFile(java.io.File f)
|
static java.lang.String |
safeGetCanonicalPath(java.io.File f)
|
static boolean |
safeIsDirectory(java.io.File f)
|
static boolean |
safeIsDirectory(java.lang.String s)
|
static boolean |
safeIsRealDirectory(java.io.File f)
|
static boolean |
safeIsRealDirectory(java.lang.String s)
|
static java.util.List |
searchDir(java.io.File dirName,
java.lang.String ext)
Returns a list of abstract pathnames that matches with the given file extension. |
static boolean |
whack(java.io.File parent)
Deletes a directory and its contents. |
static boolean |
whack(java.io.File parent,
java.util.Collection<java.io.File> undeletedFiles)
Deletes a directory and its contents. |
static void |
writeStringToFile(java.lang.String s,
java.io.File f)
Write the String to a file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileUtils()
| Method Detail |
|---|
public static java.io.File[] listFiles(java.io.File f)
public static java.io.File[] listFiles(java.io.File f,
java.io.FileFilter ff)
public static java.io.File[] listFiles(java.io.File f,
java.io.FilenameFilter fnf)
public static boolean safeIsDirectory(java.io.File f)
public static boolean safeIsRealDirectory(java.lang.String s)
public static boolean safeIsRealDirectory(java.io.File f)
public static boolean safeIsDirectory(java.lang.String s)
public static java.lang.String safeGetCanonicalPath(java.io.File f)
public static java.io.File safeGetCanonicalFile(java.io.File f)
public static boolean hasExtension(java.lang.String filename,
java.lang.String ext)
public static boolean hasExtension(java.io.File f,
java.lang.String ext)
public static boolean hasExtensionIgnoreCase(java.lang.String filename,
java.lang.String ext)
public static boolean hasExtensionIgnoreCase(java.io.File f,
java.lang.String ext)
public static boolean isLegalFilename(java.lang.String filename)
public static boolean isFriendlyFilename(java.lang.String filename)
public static java.lang.String makeLegalFilename(java.lang.String filename)
public static java.lang.String makeLegalNoBlankFileName(java.lang.String filename)
public static java.lang.String makeFriendlyFilename(java.lang.String filename)
public static java.lang.String makeFriendlyFilenameNoExtension(java.lang.String filename)
public static java.lang.String makeFriendlyFilenameExtension(java.lang.String filename)
public static java.lang.String revertFriendlyFilenameExtension(java.lang.String filename)
public static java.lang.String revertFriendlyFilename(java.lang.String filename)
public static void liquidate(java.io.File parent)
public static boolean isJar(java.lang.String filename)
public static boolean isZip(java.lang.String filename)
public static boolean isJar(java.io.File f)
public static boolean isZip(java.io.File f)
public static boolean whack(java.io.File parent)
parent - the File at the top of the subtree to delete
public static boolean whack(java.io.File parent,
java.util.Collection<java.io.File> undeletedFiles)
parent - the File at the top of the subtree to delete
public static boolean deleteFile(java.io.File f)
f - file to delete
public static java.io.FileOutputStream openFileOutputStream(java.io.File out)
throws java.io.IOException
out - the output File for which a stream is needed
java.io.IOException - for any errors opening the stream
public static java.util.Set getAllFilesUnder(java.io.File directory,
java.io.FilenameFilter filenameFilter)
throws java.io.IOException
java.io.IOException
public static java.util.Set getAllFilesUnder(java.io.File directory,
java.io.FilenameFilter filenameFilter,
boolean relativize)
throws java.io.IOException
java.io.IOException
public static java.util.Set getAllFilesAndDirectoriesUnder(java.io.File directory)
throws java.io.IOException
java.io.IOException
public static java.io.File relativize(java.io.File parent,
java.io.File child)
public static java.lang.String formatFileCollection(java.util.Collection<java.io.File> files)
files - the Collection of File objects to be listed
public static java.io.File getDirectory(java.io.File f)
public static java.io.File createTempFile(java.io.File directory)
public static java.io.File[] listAllFiles(java.io.File dirName,
java.lang.String ext)
dirName - dir name under which search will beginext - file extension to look for
public static java.util.List searchDir(java.io.File dirName,
java.lang.String ext)
dirName - dir name under which search will beginext - file extension to look for
public static void copy(java.lang.String from,
java.lang.String to)
throws java.io.IOException
from - Name of file to copyto - Name of new file
java.io.IOException - if an error while copying the content
public static void copy(java.io.File fin,
java.io.File fout)
throws java.io.IOException
fin - File to copyfout - New file
java.io.IOException - if an error while copying the content
public static void copyTree(java.io.File din,
java.io.File dout)
throws java.io.IOException
din - File pointing at root of tree to copydout - File pointing at root of new tree
java.io.IOException - if an error while copying the contentpublic static java.lang.String makeForwardSlashes(java.lang.String inputStr)
inputStr - non null String
does not contain `\\` character public static java.lang.String quoteString(java.lang.String s)
s - input string
public static java.lang.String getIllegalFilenameCharacters()
public static void copyFile(java.io.File fin,
java.io.File fout)
throws java.io.IOException
fin - the source filefout - the destination file
java.io.IOException
public static void copy(java.io.InputStream in,
java.io.FileOutputStream out,
long size)
throws java.io.IOException
java.io.IOException
public static void copyWithoutClose(java.io.InputStream in,
java.io.FileOutputStream out,
long size)
throws java.io.IOException
java.io.IOException
public static void copy(java.io.InputStream in,
java.io.OutputStream os,
long size)
throws java.io.IOException
java.io.IOException
public static boolean renameFile(java.io.File fromFile,
java.io.File toFile)
fromFile - to be renamedtoFile - name for the renamed file
public static void appendText(java.lang.String fileName,
java.lang.String line)
throws java.lang.RuntimeException
fileName - name of the text file that needs to be appended toline - the line to append to
java.lang.RuntimeException - in case of any error - that makes it callable
from a code not within try-catch. Note that NPE will be thrown if either
argument is null.
Note that this method is not tested with String containing characters
with 2 bytes.
public static void appendText(java.lang.String fileName,
java.lang.StringBuffer buffer)
throws java.io.IOException,
java.io.FileNotFoundException
java.io.IOException
java.io.FileNotFoundException
public static java.lang.String readSmallFile(java.lang.String fileName)
throws java.io.IOException,
java.io.FileNotFoundException
small .
fileName - String representing absolute path of the file
java.io.IOException - if there is an i/o error.
java.io.FileNotFoundException - if the file could not be found
public static java.lang.String readSmallFile(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.io.File getManagedFile(java.lang.String file,
java.io.File dir)
throws java.io.IOException
file - - path to look fordir - - directory where the path file should exist
java.io.IOException
public static void writeStringToFile(java.lang.String s,
java.io.File f)
throws java.io.IOException
s - The String to write to the filef - The file to write the String to
java.io.IOException - if any errors
public static java.io.File[] findFilesInDir(java.io.File dir,
java.lang.String regexp)
dir - the directory to searchregexp - the regular expression pattern
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||