public class FileUtil extends Object
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
backupFile(File f)
Backups the given file using the
getBackupFile(File) as
destination file. |
static void |
copyFile(File source,
File target)
Copy a file to a given locationand logging.
|
static boolean |
createDirectoryIfNecessary(File dir)
Creates the directory (and his parents) if necessary.
|
static boolean |
createNewFile(File file) |
static void |
deleteFile(File file)
Delete the given file.
|
static File |
getBackupFile(File file) |
static File |
getFile(File base,
String... paths) |
static List<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 void |
tryClose(InputStream is) |
static void |
tryClose(OutputStream os) |
public static void tryClose(InputStream is)
public static void tryClose(OutputStream os)
public static boolean createDirectoryIfNecessary(File dir) throws IOException
dir - the directory to create if not exisitingtrue if directory was created, false if was no
need to create itIOException - if could not create directorypublic static boolean createNewFile(File file) throws IOException
IOExceptionpublic static void deleteFile(File file) throws IOException
file - the file to deleteIOException - if could not delete the filepublic static void renameFile(File file, File destination) throws IOException
file - the file to renamedestination - the destination fileIOException - if could not rename the filepublic static void copyFile(File source, File target) throws IOException
source - represents the file to copy.target - file name of destination file.IOException - if could not copy file.public static File getBackupFile(File file)
file - the source filepublic static void backupFile(File f) throws IOException
getBackupFile(File) as
destination file.f - the file to backupIOException - if any pb while copying the filepublic static String readAsString(File file, String encoding) throws IOException
file - le fichier a lireencoding - encoding to read fileIOException - if IO pbpublic static void printString(File file, String content, String encoding) throws IOException
file - the file to write tocontent - the content to writeencoding - the encoding to write inIOException - if IO pbpublic static List<File> orderFiles(Collection<File> files)
Copyright © 2010–2023. All rights reserved.