com.ebmwebsourcing.easycommons.io
Class FileSystemHelper

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

public final class FileSystemHelper
extends Object

Author:
Marc Jambert - EBM WebSourcing, Christophe DENEUX - Linagora

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

createTempDir

public static File createTempDir()
                          throws IOException
Throws:
IOException

createTempDir

public static File createTempDir(String prefix)
                          throws IOException
Throws:
IOException

createTempDir

public static File createTempDir(File parentDir,
                                 String prefix)
                          throws IOException
Throws:
IOException

cleanDirectory

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

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

forceDelete

public static void forceDelete(File file)
                        throws 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:
NullPointerException - if the directory is null
IOException - in case deletion is unsuccessful

getRelativePath

@Deprecated
public 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/ )

Return relative path.

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


getRelativePath

public static String getRelativePath(File sourcePath,
                                     File targetPath)
Return relative path.


Copyright © 2015 Petals Link. All rights reserved.