Package org.codehaus.mojo.license.utils
Class FileUtil
java.lang.Object
org.codehaus.mojo.license.utils.FileUtil
Some basic file io utilities
- Since:
- 1.0
- Author:
- pgier, tchemit dev@tchemit.fr
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
backupFile
(File f) Backups the given file using thegetBackupFile(File)
as destination file.static void
Copy a file to a given locationand logging.static File
getBackupFile
(File file) orderFiles
(Collection<File> files) static void
printString
(File file, String content, String encoding) Print content to file.static String
readAsString
(File file, String encoding) Permet de lire un fichier et de retourner sont contenu sous forme d'une chaine de carateres.static void
renameFile
(File file, File destination) Rename the given file to a new destination.static String
static String
toExtension
(String mimeType, boolean throwDefault)
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
renameFile
Rename the given file to a new destination.- Parameters:
file
- the file to renamedestination
- the destination file- Throws:
IOException
- if could not rename the file
-
copyFile
Copy a file to a given locationand logging.- Parameters:
source
- represents the file to copy.target
- file name of destination file.- Throws:
IOException
- if could not copy file.
-
getBackupFile
- Parameters:
file
- the source file- Returns:
- the backup file
-
backupFile
Backups the given file using thegetBackupFile(File)
as destination file.- Parameters:
f
- the file to backup- Throws:
IOException
- if any pb while copying the file
-
readAsString
Permet de lire un fichier et de retourner sont contenu sous forme d'une chaine de carateres.- Parameters:
file
- le fichier a lireencoding
- encoding to read file- Returns:
- the content of the file
- Throws:
IOException
- if IO pb
-
printString
Print content to file. This method ensures that a platform specific line ending is used.- Parameters:
file
- the file to write tocontent
- the content to writeencoding
- the encoding to write in- Throws:
IOException
- if IO pb
-
orderFiles
-
sha1
- Throws:
IOException
-
toExtension
-