|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deduced.utilities.FileUtilities
public class FileUtilities

Utility methods used on files.
| Field Summary | |
|---|---|
static int |
CREATE_CODE
code returned when a file was created |
private static java.lang.String |
DOT
Dot file name |
static java.lang.String |
FOLDER_SEPARATOR
folder separator constant |
static int |
IGNORED_CODE
code returned when a file was ignored |
static int |
MODIFIED_CODE
code returned when a file was modified |
static int |
READ_BUFFER_SIZE
buffer size used to read files |
| Constructor Summary | |
|---|---|
FileUtilities()
|
|
| Method Summary | |
|---|---|
static void |
closeQuietly(java.util.zip.ZipFile input)
close a zip file quietly. |
protected static void |
copyPathSkipDot(java.lang.String[] path,
java.util.List<java.lang.String> target)
copy a list of path fragments into a target list and skip all the useless parts (such as the "." path) |
static java.lang.String |
extractRelativePath(java.lang.String sourcePath,
java.lang.String targetPath)
extract a relative path between a source directory and a target directory or file. |
static java.lang.String |
extractRelativePathToWorkingDirectory(java.lang.String filePath)
extract a relative file path from the current working directory |
static boolean |
fileExists(java.lang.String filePath)
test if a file exists based on a path |
static void |
forceCreateDirectory(java.lang.String folderName)
force a directory creation |
static java.lang.String |
getCurrentWorkingDirectory()
|
static java.io.InputStream |
getFileContentStream(java.lang.String fileName)
get File Content Stream using either a system resource or a file system reference. |
static java.io.InputStream |
getMandatoryFileContentStream(java.lang.String fileName)
get File Content Stream using either a system resource or a file system reference. |
static boolean |
isFileReadOnly(java.lang.String filePath)
test if a file is read only. |
static boolean |
isFileResource(java.lang.String filePath)
test if a file can be reached as a resource. |
static boolean |
isStreamContentEqual(java.io.InputStream readStream,
java.io.InputStream secondStream)
check if 2 streams have the same content |
static java.lang.String |
mergeFolderName(java.lang.String parentFolderName,
java.lang.String subFolderName)
merge two folder names together. |
static void |
overwriteFileContent(java.lang.String fileName,
byte[] content)
overwrite the content of a file, whatever the previous content was |
static int |
writeFileContent(java.lang.String fileName,
byte[] content)
write the file content |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String FOLDER_SEPARATOR
private static final java.lang.String DOT
public static final int READ_BUFFER_SIZE
public static final int CREATE_CODE
public static final int MODIFIED_CODE
public static final int IGNORED_CODE
| Constructor Detail |
|---|
public FileUtilities()
| Method Detail |
|---|
public static int writeFileContent(java.lang.String fileName,
byte[] content)
throws java.io.IOException
fileName - the name of the filecontent - content of the file
java.io.IOException - any error generated when accessing the file
public static void overwriteFileContent(java.lang.String fileName,
byte[] content)
throws java.io.IOException
fileName - the file namecontent - the file content
java.io.IOException - any error that occurred while accessing the file
public static boolean isStreamContentEqual(java.io.InputStream readStream,
java.io.InputStream secondStream)
readStream - the first streamsecondStream - the second stream
public static java.lang.String extractRelativePath(java.lang.String sourcePath,
java.lang.String targetPath)
sourcePath - the source folder to extract a relative path, must be
an absolute pathtargetPath - the target file or folder to extract a relative path,
must be an absolute path
protected static void copyPathSkipDot(java.lang.String[] path,
java.util.List<java.lang.String> target)
path - the path fragmentstarget - the target list that receives the path fragmentspublic static java.lang.String extractRelativePathToWorkingDirectory(java.lang.String filePath)
filePath - the absolute file path to differentiate from the current
working directory
public static java.lang.String getCurrentWorkingDirectory()
public static boolean isFileReadOnly(java.lang.String filePath)
filePath - the file path
public static boolean isFileResource(java.lang.String filePath)
filePath - the file path
public static boolean fileExists(java.lang.String filePath)
filePath - the file path
public static java.lang.String mergeFolderName(java.lang.String parentFolderName,
java.lang.String subFolderName)
Execution example:
mergeFolderName("", "abc/def") = "abc/def"
mergeFolderName(null, "abc/def") = "abc/def"
mergeFolderName("test/me", null) = "test/me"
mergeFolderName("test/me", "abc/def") = "test/me/abc/def"
mergeFolderName("test/me/", "abc/def") = "test/me/abc/def"
parentFolderName - the parent folder namesubFolderName - the child folder name
public static void forceCreateDirectory(java.lang.String folderName)
throws java.io.IOException
folderName - the folder name
java.io.IOException - any error encountered during the creation
public static java.io.InputStream getFileContentStream(java.lang.String fileName)
throws java.io.IOException
fileName - file name
java.io.IOException - for read errors.
public static java.io.InputStream getMandatoryFileContentStream(java.lang.String fileName)
throws java.io.IOException
fileName - file name
java.io.IOException - for read errors.public static void closeQuietly(java.util.zip.ZipFile input)
input - the zip file to close
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||