fr.paris.lutece.maven
Class FileUtils

java.lang.Object
  extended by org.codehaus.plexus.util.FileUtils
      extended by fr.paris.lutece.maven.FileUtils

public class FileUtils
extends org.codehaus.plexus.util.FileUtils

Utility class to manipulate files.
Note : these methods were copied from plexus-utils 1.2 because :


Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.plexus.util.FileUtils
org.codehaus.plexus.util.FileUtils.FilterWrapper
 
Field Summary
protected static String REGEXP_SITE_RESOURCES_XML
           
protected static String REGEXP_SITE_TECH
           
protected static String REGEXP_SITE_TECH_DIRECTORY
           
protected static String REGEXP_SITE_XDOC_XML
           
protected static String REGEXP_SITE_XML
           
 
Fields inherited from class org.codehaus.plexus.util.FileUtils
FS, ONE_GB, ONE_KB, ONE_MB
 
Constructor Summary
FileUtils()
           
 
Method Summary
static void copyDirectoryStructure(File sourceDirectory, File destinationDirectory)
          Copies an entire directory structure.
static void copyDirectoryStructureIfModified(File sourceDirectory, File destinationDirectory)
          Copies an entire directory structure but only source files with timestamp later than the destinations'.
static void copyFile(File source, File destination)
          Copy file from source to destination.
static boolean copyFileIfModified(File source, File destination)
          Copy file from source to destination only if source timestamp is later than the destination timestamp.
static void copyFileToDirectoryIfModified(File source, File destinationDirectory)
          Copy file from source to destination only if source is newer than the target file.
static void createFile(String strFolderPath, String strFileName, String strFileOutPut)
          Create a file.
static void deleteFile(String strFolderPath, String strFileName)
          Delete a file
static int getNbFileCopy()
          Gets the nb file copy.
static int getNbFileModified()
          Gets the nb file modified.
static String readLastLine(String strFile)
          Read the last line from the given file
static void setNbFileCopy(int nbFileCopy)
          Sets the nb file copy.
static void setNbFileModified(int nbFileMdofied)
          Sets the nb file modified.
static void writeToFile(String strContent, String strFile)
          Write to the given file
 
Methods inherited from class org.codehaus.plexus.util.FileUtils
basename, basename, byteCountToDisplaySize, catPath, cleanDirectory, cleanDirectory, contentEquals, copyDirectory, copyDirectory, copyDirectoryLayout, copyFile, copyFile, copyFileToDirectory, copyFileToDirectory, copyFileToDirectoryIfModified, copyStreamToFile, copyURLToFile, createTempFile, deleteDirectory, deleteDirectory, dirname, extension, fileAppend, fileAppend, fileDelete, fileExists, filename, fileRead, fileRead, fileRead, fileRead, fileWrite, fileWrite, fileWrite, fileWrite, forceDelete, forceDelete, forceDeleteOnExit, forceMkdir, getDefaultExcludes, getDefaultExcludesAsList, getDefaultExcludesAsString, getDirectoryNames, getDirectoryNames, getExtension, getFile, getFileAndDirectoryNames, getFileNames, getFileNames, getFiles, getFiles, getFilesFromExtension, getPath, getPath, isValidWindowsFileName, loadFile, mkdir, normalize, removeExtension, removePath, removePath, rename, resolveFile, sizeOfDirectory, sizeOfDirectory, toFile, toURLs, waitFor, waitFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGEXP_SITE_XDOC_XML

protected static final String REGEXP_SITE_XDOC_XML
See Also:
Constant Field Values

REGEXP_SITE_RESOURCES_XML

protected static final String REGEXP_SITE_RESOURCES_XML
See Also:
Constant Field Values

REGEXP_SITE_TECH

protected static final String REGEXP_SITE_TECH
See Also:
Constant Field Values

REGEXP_SITE_TECH_DIRECTORY

protected static final String REGEXP_SITE_TECH_DIRECTORY
See Also:
Constant Field Values

REGEXP_SITE_XML

protected static final String REGEXP_SITE_XML
See Also:
Constant Field Values
Constructor Detail

FileUtils

public FileUtils()
Method Detail

getNbFileModified

public static int getNbFileModified()
Gets the nb file modified.

Returns:
the nb file modified

setNbFileModified

public static void setNbFileModified(int nbFileMdofied)
Sets the nb file modified.

Parameters:
nbFileMdofied - the new nb file modified

getNbFileCopy

public static int getNbFileCopy()
Gets the nb file copy.

Returns:
the nb file copy

setNbFileCopy

public static void setNbFileCopy(int nbFileCopy)
Sets the nb file copy.

Parameters:
nbFileCopy - the new nb file copy

copyDirectoryStructureIfModified

public static void copyDirectoryStructureIfModified(File sourceDirectory,
                                                    File destinationDirectory)
                                             throws IOException
Copies an entire directory structure but only source files with timestamp later than the destinations'. Note:

Parameters:
sourceDirectory - the source directory.
destinationDirectory - the destination directory.
Throws:
IOException - if an I/O exception occurs.

copyDirectoryStructure

public static void copyDirectoryStructure(File sourceDirectory,
                                          File destinationDirectory)
                                   throws IOException
Copies an entire directory structure. Note:

Parameters:
sourceDirectory - the source directory.
destinationDirectory - the destination directory.
Throws:
IOException - if an I/O exception occurs.

copyFileToDirectoryIfModified

public static void copyFileToDirectoryIfModified(File source,
                                                 File destinationDirectory)
                                          throws IOException
Copy file from source to destination only if source is newer than the target file. If destinationDirectory does not exist, it (and any parent directories) will be created. If a file source in destinationDirectory exists, it will be overwritten.

Parameters:
source - An existing File to copy.
destinationDirectory - A directory to copy source into.
Throws:
FileNotFoundException - if source isn't a normal file.
IllegalArgumentException - if destinationDirectory isn't a directory.
IOException - if source does not exist, the file in destinationDirectory cannot be written to, or an IO error occurs during copying.

copyFileIfModified

public static boolean copyFileIfModified(File source,
                                         File destination)
                                  throws IOException
Copy file from source to destination only if source timestamp is later than the destination timestamp. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

Parameters:
source - An existing non-directory File to copy bytes from.
destination - A non-directory File to write bytes to (possibly overwriting).
Throws:
IOException - if source does not exist, destination cannot be written to, or an IO error occurs during copying.
FileNotFoundException - if destination is a directory (use FileUtils.copyFileToDirectory(java.lang.String, java.lang.String)).

copyFile

public static void copyFile(File source,
                            File destination)
                     throws IOException
Copy file from source to destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

Parameters:
source - An existing non-directory File to copy bytes from.
destination - A non-directory File to write bytes to (possibly overwriting).
Throws:
IOException - if source does not exist, destination cannot be written to, or an IO error occurs during copying.
FileNotFoundException - if destination is a directory (use FileUtils.copyFileToDirectory(java.lang.String, java.lang.String)).

createFile

public static void createFile(String strFolderPath,
                              String strFileName,
                              String strFileOutPut)
                       throws IOException
Create a file.

Parameters:
strFolderPath - the folder path
strFileName - the file name
strFileOutPut - the file output
Throws:
IOException - exception if there is an error during the deletion

deleteFile

public static void deleteFile(String strFolderPath,
                              String strFileName)
                       throws IOException
Delete a file

Parameters:
strFolderPath - the folder path
strFileName - the file name
Throws:
IOException - exception if there is an error during the deletion

readLastLine

public static String readLastLine(String strFile)
Read the last line from the given file

Parameters:
strFile - the file absolute path (ex : /home/filetopath/file.txt)
Returns:
the last line, an empty string if the file does not exists

writeToFile

public static void writeToFile(String strContent,
                               String strFile)
Write to the given file

Parameters:
strContent - the content to write
strFile - the file


Copyright © 2006-2013 Mairie de Paris. All Rights Reserved.