public class Files extends Object
| Modifier and Type | Field and Description |
|---|---|
static char[] |
ILLEGAL_FILENAME_CHARS
Characters that are invalid in Windows OS file names (Unix only forbids '/' character)
|
static char |
ILLEGAL_FILENAME_CHARS_REPLACE |
| Constructor and Description |
|---|
Files() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(File from,
File to)
Just copy a file
|
static boolean |
copyDir(File from,
File to) |
static boolean |
delete(File file)
Just delete a file.
|
static boolean |
deleteDirectory(File path)
Recursively delete a directory.
|
static String |
sanitizeFileName(String fileName)
Replace all characters that are invalid in file names on Windows or Unix operating systems
with
ILLEGAL_FILENAME_CHARS_REPLACE character. |
static String |
sanitizeFileName(String fileName,
char replacement)
Replace all characters that are invalid in file names on Windows or Unix operating systems
with passed in character.
|
static void |
unzip(File from,
File to) |
static void |
zip(File directory,
File zipFile) |
public static final char[] ILLEGAL_FILENAME_CHARS
public static final char ILLEGAL_FILENAME_CHARS_REPLACE
public static boolean delete(File file)
file - The file to deletepublic static boolean deleteDirectory(File path)
public static String sanitizeFileName(String fileName)
ILLEGAL_FILENAME_CHARS_REPLACE character.
This method makes sure your file name can successfully be used to write new file to disk.
Invalid characters are listed in ILLEGAL_FILENAME_CHARS array.fileName - File name to sanitizepublic static String sanitizeFileName(String fileName, char replacement)
ILLEGAL_FILENAME_CHARS array.fileName - File name to sanitizereplacement - character to use as replacement for invalid charsGuillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly