com.ebmwebsourcing.easycommons.io
Class FileSystemHelper

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.io.FileSystemHelper

public final class FileSystemHelper
extends java.lang.Object

Author:
Marc Jambert - EBM WebSourcing

Method Summary
static void cleanDirectory(java.io.File directory)
          Cleans a directory without deleting it.
static java.io.File createTempDir()
           
static java.io.File createTempDir(java.io.File parentDir, java.lang.String prefix)
           
static java.io.File createTempDir(java.lang.String prefix)
           
static void forceDelete(java.io.File file)
          Deletes a file.
static java.lang.String getRelativePath(java.lang.String source, java.lang.String target)
          Return relative path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createTempDir

public static java.io.File createTempDir()
                                  throws java.io.IOException
Throws:
java.io.IOException

createTempDir

public static java.io.File createTempDir(java.lang.String prefix)
                                  throws java.io.IOException
Throws:
java.io.IOException

createTempDir

public static java.io.File createTempDir(java.io.File parentDir,
                                         java.lang.String prefix)
                                  throws java.io.IOException
Throws:
java.io.IOException

cleanDirectory

public static void cleanDirectory(java.io.File directory)
                           throws java.io.IOException
Cleans a directory without deleting it.

Parameters:
directory - directory to clean
Throws:
java.io.IOException - in case cleaning is unsuccessful

forceDelete

public static void forceDelete(java.io.File file)
                        throws java.io.IOException
Deletes a file. If file is a directory, delete it and all sub-directories.

The difference between File.delete() and this method are:

Parameters:
file - file or directory to delete, must not be null
Throws:
java.lang.NullPointerException - if the directory is null
java.io.IOException - in case deletion is unsuccessful

getRelativePath

public static java.lang.String getRelativePath(java.lang.String source,
                                               java.lang.String target)
Return relative path.

WARNING:
Folder path must finished with the character: File.separator



Copyright © 2012 Petals Link. All Rights Reserved.