|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.metamatrix.core.util.FileUtils
public final class FileUtils
Nested Class Summary | |
---|---|
static interface |
FileUtils.Constants
|
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
|
static java.lang.String |
JAVA_IO_TEMP_DIR
|
static java.lang.String |
LINE_SEPARATOR
|
static char[] |
LINE_SEPARATOR_CHARS
|
static char |
SEPARATOR
|
static char[] |
SUFFIX_class
|
static char[] |
SUFFIX_CLASS
|
static char[] |
SUFFIX_jar
|
static char[] |
SUFFIX_JAR
|
static char[] |
SUFFIX_java
|
static char[] |
SUFFIX_JAVA
|
static char[] |
SUFFIX_zip
|
static char[] |
SUFFIX_ZIP
|
static java.lang.String |
TEMP_DIRECTORY
|
Method Summary | |
---|---|
static java.lang.String |
buildDirectoryPath(java.lang.String[] paths)
Builds a file directory path from a physical location and a location that needs to be appended to the physical. |
static java.io.File |
convertByteArrayToFile(byte[] contents,
java.lang.String parentDirectoryPath,
java.lang.String fileName)
|
static void |
copy(java.lang.String fromFileName,
java.lang.String toFileName)
Copy a file. |
static void |
copy(java.lang.String fromFileName,
java.lang.String toFileName,
boolean overwrite)
Copy a file |
static void |
copyDirectoriesRecursively(java.io.File sourceDirectory,
java.io.File targetDirectory)
Copy recursively the sourceDirectory and all its contents
to the targetDirectory . |
static void |
copyDirectoryContentsRecursively(java.io.File sourceDirectory,
java.io.File targetDirectory)
Copy recursively the contents of sourceDirectory to
the targetDirectory . |
static void |
copyFile(java.lang.String orginDirectory,
java.lang.String destDirectory,
java.lang.String fileName)
Copy file from orginating directory to the destination directory. |
static void |
copyFile(java.lang.String orginDirectory,
java.lang.String orginFileName,
java.lang.String destDirectory,
java.lang.String destFileName)
Copy file from orginating directory to the destination directory. |
static java.io.File[] |
findAllFilesInDirectory(java.lang.String dir)
Returns a File array that will contain all the files that exist in the directory |
static java.io.File[] |
findAllFilesInDirectoryHavingExtension(java.lang.String dir,
java.lang.String extension)
Returns a File array that will contain all the files that
exist in the directory that have the specified extension. |
static java.io.File[] |
findAllFilesInDirectoryRecursively(java.lang.String dir)
Returns a File array that will contain all the files that
exist in the specified directory or any nested directories |
static java.lang.String |
getBaseFileNameWithoutExtension(java.lang.String path)
|
static long |
getCheckSum(java.io.File f)
Compute checksum for the given file. |
static java.lang.String |
getExtension(java.io.File theFile)
Obtains the file extension of the specified File . |
static java.lang.String |
getExtension(java.lang.String theFileName)
Obtains the file extension of the specified file name. |
static java.lang.String |
getFilenameWithoutExtension(java.lang.String filename)
|
static boolean |
isArchiveFileName(java.lang.String name)
Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip") implementation is not creating extra strings. |
static boolean |
isClassFileName(java.lang.String name)
Returns true iff str.toLowerCase().endsWith(".class") implementation is not creating extra strings. |
static boolean |
isFilenameValid(java.lang.String newName)
Determine whether the specified name is valid for a file or folder on the current file system. |
static boolean |
isJavaFileName(java.lang.String name)
Returns true iff str.toLowerCase().endsWith(".java") implementation is not creating extra strings. |
static void |
remove(java.lang.String filePath)
|
static void |
removeChildrenRecursively(java.io.File directory)
|
static void |
removeDirectoryAndChildren(java.io.File directory)
|
static void |
rename(java.lang.String oldFilePath,
java.lang.String newFilePath,
boolean overwrite)
Rename a file. |
static void |
testDirectoryPermissions(java.lang.String dirPath)
Test whether it's possible to read and write files in the specified directory. |
static java.lang.String |
toFileNameWithExtension(java.lang.String name,
java.lang.String extension)
Convert the specified file name to end with the specified extension if it doesn't already end with an extension. |
static java.lang.String |
toFileNameWithExtension(java.lang.String name,
java.lang.String extension,
boolean force)
Convert the specified file name to end with the specified extension if it doesn't already end with an extension. |
static void |
write(byte[] data,
java.io.File file)
Write a byte array to a file. |
static void |
write(byte[] data,
java.lang.String fileName)
Write a byte array to a file. |
static void |
write(java.io.File f,
java.io.OutputStream outputStream)
Write an File to an OutputStream Note: this will not close the outputStream; |
static void |
write(java.io.File f,
java.io.OutputStream outputStream,
int bufferSize)
Write an File to an OutputStream Note: this will not close the outputStream; |
static void |
write(java.io.InputStream is,
java.io.File f)
Write an InputStream to a file. |
static void |
write(java.io.InputStream is,
java.io.File f,
int bufferSize)
Write an InputStream to a file. |
static void |
write(java.io.InputStream fis,
java.io.OutputStream outputStream,
int bufferSize)
Write the given input stream to outputstream Note: this will not close in/out streams |
static void |
write(java.io.InputStream is,
java.lang.String fileName)
Write an InputStream to a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char SEPARATOR
public static int DEFAULT_BUFFER_SIZE
public static java.lang.String TEMP_DIRECTORY
public static java.lang.String LINE_SEPARATOR
public static char[] LINE_SEPARATOR_CHARS
public static final java.lang.String JAVA_IO_TEMP_DIR
public static final char[] SUFFIX_class
public static final char[] SUFFIX_CLASS
public static final char[] SUFFIX_java
public static final char[] SUFFIX_JAVA
public static final char[] SUFFIX_jar
public static final char[] SUFFIX_JAR
public static final char[] SUFFIX_zip
public static final char[] SUFFIX_ZIP
Method Detail |
---|
public static java.lang.String toFileNameWithExtension(java.lang.String name, java.lang.String extension)
Convert the specified file name to end with the specified extension if it doesn't already end with an extension.
name
- The file name.extension
- The extension to append to the file name.
public static java.lang.String toFileNameWithExtension(java.lang.String name, java.lang.String extension, boolean force)
Convert the specified file name to end with the specified extension if it doesn't already end with an extension. If force is true, the specified extension will be appended to the name if the name doesn't end with that particular extension.
name
- The file name.extension
- The extension to append to the file name.force
- Indicates whether to force the specified extension as the extension of the file name.
public static boolean isFilenameValid(java.lang.String newName)
newName
- the new name to be checked
public static void copy(java.lang.String fromFileName, java.lang.String toFileName) throws java.io.IOException
fromFileName
- toFileName
-
java.lang.Exception
java.io.IOException
public static void copy(java.lang.String fromFileName, java.lang.String toFileName, boolean overwrite) throws java.io.IOException
fromFileName
- toFileName
- overwrite
- whether to overwrite the destination file if it exists.
MetaMatrixCoreException
java.io.IOException
public static void copyDirectoryContentsRecursively(java.io.File sourceDirectory, java.io.File targetDirectory) throws java.lang.Exception
sourceDirectory
to
the targetDirectory
. Note that sourceDirectory
will NOT be copied. If targetDirectory
does not exist, it will be created.
sourceDirectory
- The source directory to copytargetDirectory
- The target directory to copy to
java.lang.Exception
- If the source directory does not exist.public static void copyFile(java.lang.String orginDirectory, java.lang.String destDirectory, java.lang.String fileName) throws java.lang.Exception
orginDirectory
- destDirectory
- fileName
-
java.lang.Exception
public static void copyFile(java.lang.String orginDirectory, java.lang.String orginFileName, java.lang.String destDirectory, java.lang.String destFileName) throws java.lang.Exception
orginDirectory
- orginFileName
- destDirectory
- destFileName
-
java.lang.Exception
public static void copyDirectoriesRecursively(java.io.File sourceDirectory, java.io.File targetDirectory) throws java.lang.Exception
sourceDirectory
and all its contents
to the targetDirectory
. If targetDirectory
does not exist, it will be created.
sourceDirectory
- The source directory to copytargetDirectory
- The target directory to copy to
java.lang.Exception
- If the source directory does not exist.public static void write(java.io.InputStream is, java.lang.String fileName) throws java.io.IOException
java.io.IOException
public static void write(java.io.InputStream is, java.io.File f) throws java.io.IOException
java.io.IOException
public static void write(java.io.InputStream is, java.io.File f, int bufferSize) throws java.io.IOException
java.io.IOException
public static void write(java.io.File f, java.io.OutputStream outputStream) throws java.io.IOException
java.io.IOException
public static void write(java.io.File f, java.io.OutputStream outputStream, int bufferSize) throws java.io.IOException
java.io.IOException
public static void write(java.io.InputStream fis, java.io.OutputStream outputStream, int bufferSize) throws java.io.IOException
java.io.IOException
public static void write(byte[] data, java.lang.String fileName) throws java.io.IOException
java.io.IOException
public static void write(byte[] data, java.io.File file) throws java.io.IOException
java.io.IOException
public static java.io.File[] findAllFilesInDirectoryRecursively(java.lang.String dir)
File
array that will contain all the files that
exist in the specified directory or any nested directories
public static java.io.File[] findAllFilesInDirectory(java.lang.String dir)
File
array that will contain all the files that exist in the directory
public static java.io.File[] findAllFilesInDirectoryHavingExtension(java.lang.String dir, java.lang.String extension)
File
array that will contain all the files that
exist in the directory that have the specified extension.
public static java.lang.String getFilenameWithoutExtension(java.lang.String filename)
string
-
public static java.lang.String getBaseFileNameWithoutExtension(java.lang.String path)
public static java.lang.String getExtension(java.io.File theFile)
File
. The extension is considered to be all the
characters after the last occurrence of FileUtils.Constants.FILE_EXTENSION_SEPARATOR_CHAR
in the pathname
of the input.
theFile
- the file whose extension is being requested
null
if not foundpublic static java.lang.String getExtension(java.lang.String theFileName)
FileUtils.Constants.FILE_EXTENSION_SEPARATOR_CHAR
.
theFileName
- the file whose extension is being requested
null
if not foundpublic static final boolean isArchiveFileName(java.lang.String name)
public static final boolean isClassFileName(java.lang.String name)
public static final boolean isJavaFileName(java.lang.String name)
public static java.io.File convertByteArrayToFile(byte[] contents, java.lang.String parentDirectoryPath, java.lang.String fileName)
public static void removeDirectoryAndChildren(java.io.File directory)
public static void removeChildrenRecursively(java.io.File directory)
public static java.lang.String buildDirectoryPath(java.lang.String[] paths)
physicalDirectory
- appendLocation
-
public static long getCheckSum(java.io.File f) throws java.lang.Exception
f
- The file for which checksum needs to be computed
java.lang.Exception
public static void testDirectoryPermissions(java.lang.String dirPath) throws MetaMatrixCoreException
dirPath
- Name of the directory to test
MetaMatrixException
MetaMatrixCoreException
public static void rename(java.lang.String oldFilePath, java.lang.String newFilePath, boolean overwrite) throws java.io.IOException
oldFilePath
- newFilePath
- overwrite
- If true, overwrite the old file if it exists. If false, throw an exception if the old file exists.
MetaMatrixCoreException
java.io.IOException
public static void remove(java.lang.String filePath) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |