|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ebmwebsourcing.easycommons.io.FileSystemHelper
public final class FileSystemHelper
| Method Summary | |
|---|---|
static void |
cleanDirectory(File directory)
Cleans a directory without deleting it. |
static File |
createTempDir()
|
static File |
createTempDir(File parentDir,
String prefix)
|
static File |
createTempDir(String prefix)
|
static void |
forceDelete(File file)
Deletes a file. |
static String |
getRelativePath(File sourcePath,
File targetPath)
Return relative path. |
static String |
getRelativePath(String source,
String target)
Deprecated. Use getRelativePath(File, File) that
manages correctly non-relative paths and returns a correct
value for relative sub-directories (./dir1/dir2/
) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static File createTempDir()
throws IOException
IOException
public static File createTempDir(String prefix)
throws IOException
IOException
public static File createTempDir(File parentDir,
String prefix)
throws IOException
IOException
public static void cleanDirectory(File directory)
throws IOException
directory - directory to clean
IOException - in case cleaning is unsuccessful
public static void forceDelete(File file)
throws IOException
The difference between File.delete() and this method are:
file - file or directory to delete, must not be null
NullPointerException - if the directory is null
IOException - in case deletion is unsuccessful
@Deprecated
public static String getRelativePath(String source,
String target)
getRelativePath(File, File) that
manages correctly non-relative paths and returns a correct
value for relative sub-directories (./dir1/dir2/
)
WARNING: Folder path must finished with the character:
File.separator
| source | target | relative path |
| /root/dir1/dir2/ | /root/dir1/ | ../ |
| /root/ | /root/dir1/dir2/ | dir1/dir2/ |
| /root/dir1/dir2/ | /root/test.xml | ../../test.xml |
source - path of the source foldertarget - path of the target folder/file
public static String getRelativePath(File sourcePath,
File targetPath)
sourcePath |
targetPath |
relative path |
| /root/dir1/dir2/ | /root/dir1/ | ../ |
| /root/ | /root/dir1/dir2/ | ./dir1/dir2/ |
| /root/dir1/dir2/ | /root/test.xml | ../../test.xml |
| /root/ | /notrelative/dir1/ | /notrelative/dir1/ |
| /root/dir1 | /notrelative/test.xml | /notrelative/test.xml |
sourcePath - path of the source folder. MUST be an absolute directory. Not null.targetPath - path of the target folder/file to relativize against sourcePath. MUST be an
absolute File. Not null
targetPath if paths are not relative
IllegalArgumentException - if parameters are invalid
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||