public class Files
extends java.lang.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(java.io.File from,
java.io.File to)
Just copy a file
|
static boolean |
copyDir(java.io.File from,
java.io.File to) |
static boolean |
delete(java.io.File file)
Just delete a file.
|
static boolean |
deleteDirectory(java.io.File path)
Recursively delete a directory.
|
static boolean |
isSameFile(java.io.File a,
java.io.File b)
Indicate if two file refers to the same one
|
static java.lang.String |
sanitizeFileName(java.lang.String fileName)
Replace all characters that are invalid in file names on Windows or Unix operating systems with
ILLEGAL_FILENAME_CHARS_REPLACE character. |
static java.lang.String |
sanitizeFileName(java.lang.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(java.io.File from,
java.io.File to) |
static void |
zip(java.io.File directory,
java.io.File zipFile) |
public static final char[] ILLEGAL_FILENAME_CHARS
public static final char ILLEGAL_FILENAME_CHARS_REPLACE
public static boolean isSameFile(java.io.File a, java.io.File b)
a
- First file to compareb
- Second file to comparepublic static void copy(java.io.File from, java.io.File to)
from
- source of the fileto
- destination filepublic static boolean delete(java.io.File file)
file
- The file to deletepublic static boolean deleteDirectory(java.io.File path)
path
- Path of the directorypublic static boolean copyDir(java.io.File from, java.io.File to)
public static void unzip(java.io.File from, java.io.File to)
public static void zip(java.io.File directory, java.io.File zipFile)
public static java.lang.String sanitizeFileName(java.lang.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 java.lang.String sanitizeFileName(java.lang.String fileName, char replacement)
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 sanitizereplacement
- character to use as replacement for invalid charsGuillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly