public interface IOUtils
| Modifier and Type | Method and Description |
|---|---|
void |
assertCanRead(String dir)
Check whether the dir is readable
|
void |
assertCanWrite(String dir)
Check whether the dir is writeable
|
void |
cleanDirectory(File directory)
Cleans a directory without deleting it.
|
String |
computePackage(String appName,
String applicationPackage,
String templateTag)
Compute application full name with applicationPackage.templateTag.appName
The appName is normalized
|
void |
copyDirectoryContent(File sourceDir,
File destDir)
Copy all files in sourceDir to destDir.
|
void |
copyFile(File srcFile,
File destFile)
Copy srcFile to destFile
|
void |
copyFileToDirectory(File srcFile,
File destDir)
Copy srcFile to destDir
|
void |
copyInputStreamToFile(InputStream inputStream,
File file)
Copies bytes from an inputStream to a file
file.
|
void |
createImageReference(String imageName,
int drawableId,
File tempDirectory)
Create drawable reference in res/values/public.xml
|
void |
deleteDirectory(File file)
Deletes a directory recursively.
|
void |
deleteFile(File file)
Deletes a file.
|
void |
eraseAndCopyDir(File sourceDir,
File destDir)
Cleans destDir without deleting it and copies
sourceDir whole directory its location preserving the file dates
|
String |
generateKey()
Retrieve a pseudo randomly generated UUID.
|
String |
getExtension(String name)
Retrieve file extension from file name
|
String |
getNameWithoutExtension(String name)
Retrieve file name without extension from name
|
boolean |
isMac()
Check whether the current environment is mac based
|
boolean |
isWindows()
Check whether the current environment is windows based
|
File |
locateFile(File sourceDir,
String fileRelativePath)
Locate for the file with fileRelativePath in directory sourceDir
|
long |
minToMillis(long minutes)
Convert Minutes to milliseconds
|
void |
moveFile(File srcFile,
File destFile)
Moves a file.
|
InputStream |
openClassPathResource(String path)
Finds a resource with a given name.
|
String |
parsePath(String pathToTest)
Prevents path hacks such as ../my/path or /opt/my/path
|
String |
readFileToString(File file)
Reads the contents of a file into a String
|
String |
removeExtension(String fileName)
Removes the extension from a filename
|
void |
replaceTokens(Map<String,String> model,
File srcFile,
File destFile)
Perform token replacement in a file
|
void |
replaceTokens(Object model,
Boolean exceptionHandling,
File srcDirectory,
List<String> parseList,
File destDirectory)
Deprecated.
|
String generateKey()
void copyFile(File srcFile, File destFile)
srcFile - source File to be copieddestFile - destination file to be copied tovoid copyFileToDirectory(File srcFile, File destDir)
srcFile - source File to be copieddestDir - destination directory to be copied invoid copyDirectoryContent(File sourceDir, File destDir)
sourceDir - source directory to be copieddestDir - destination directory to be copied in@Deprecated void replaceTokens(Object model, Boolean exceptionHandling, File srcDirectory, List<String> parseList, File destDirectory)
model - the model object. Any attribute name matching a token will have its value replace the tokenexceptionHandling - exception handling behavior, true: errors are thrown if parsing fails, false: errors are ignoredsrcDirectory - the source directory (read-only)parseList - the relative paths from the source directorydestDirectory - the destination directory
Warning: this method should not be used anymore, as it could create issues in the workflow in case non-custom files are modified
Use replaceTokens(java.util.Map, java.io.File, java.io.File) insteadvoid replaceTokens(Map<String,String> model, File srcFile, File destFile)
model - the model object. The key being the token name, and value the String it will be replaced bysrcFile - the source file (read-only)destFile - the destination fileFile locateFile(File sourceDir, String fileRelativePath)
sourceDir - input source directoryfileRelativePath - relative path in source directoryString computePackage(String appName, String applicationPackage, String templateTag)
appName - input application nameapplicationPackage - input application packagetemplateTag - input template tagvoid assertCanRead(String dir)
dir - input dirvoid assertCanWrite(String dir)
dir - input dirString getExtension(String name)
name - the nameString getNameWithoutExtension(String name)
name - the nameString removeExtension(String fileName)
fileName - the filename to queryvoid cleanDirectory(File directory)
directory - directory to cleanString readFileToString(File file) throws IOException
file - the file to readIOException - in case of an I/O errorvoid copyInputStreamToFile(InputStream inputStream, File file)
inputStream - the InputStream to copy bytes fromfile - the non-directory File to write bytes tovoid deleteDirectory(File file)
file - directory to deletevoid deleteFile(File file)
file - file or directory to delete, must not be nullvoid moveFile(File srcFile, File destFile)
srcFile - the file to be moveddestFile - the destination filevoid createImageReference(String imageName, int drawableId, File tempDirectory)
imageName - the name of the imagedrawableId - the drawable resource id (android)tempDirectory - the destination directorylong minToMillis(long minutes)
minutes - the number of minutesString parsePath(String pathToTest)
pathToTest - the initial pathvoid eraseAndCopyDir(File sourceDir, File destDir)
sourceDir - an existing directory to copydestDir - the new directoryInputStream openClassPathResource(String path)
path - name of the desired resourceboolean isWindows()
boolean isMac()
Copyright © 2015. All rights reserved.