public final class Files extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of the copy buffer.
|
| Constructor and Description |
|---|
Files() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(File source,
File target)
Copy a file.
|
static void |
copy(File source,
File target,
byte[] buff)
Copy a file.
|
static void |
copy(File source,
File target,
int size)
Copy a file.
|
static void |
copy(URL src,
File dest)
Copy a remote/local URL to a local file
|
static String |
decodeFileName(String name)
Used to decode a file system friendly filename produced
by encodeFileName() method, above.
|
static String |
decodeFileName(String name,
char escape)
See decodeFileName(String) above.
|
static boolean |
delete(File dir)
Delete a file, or a directory and all of its contents.
|
static boolean |
delete(String dirname)
Delete a file or directory and all of its contents.
|
static boolean |
deleteContaining(String filename)
Delete a directory contaning the given file and all its contents.
|
static String |
encodeFileName(String name)
Used to encode any string into a string that is safe to use as
a file name on most operating systems.
|
static String |
encodeFileName(String name,
char escape)
See encodeFileName(String) above.
|
static String |
findRelativePath(String base,
String path)
Build a relative path to the given base path.
|
public static final int DEFAULT_BUFFER_SIZE
public static boolean delete(File dir)
dir - The directory or file to delete.public static boolean delete(String dirname)
dirname - The name of the file or directory to delete.public static boolean deleteContaining(String filename)
filename - a file or directory in the containing directory to deletepublic static void copy(File source, File target, byte[] buff) throws IOException
source - Source file to copy.target - Destination target file.buff - The copy buffer.IOException - Failed to copy file.public static void copy(File source, File target, int size) throws IOException
source - Source file to copy.target - Destination target file.size - The size of the copy buffer.IOException - Failed to copy file.public static void copy(File source, File target) throws IOException
source - Source file to copy.target - Destination target file.IOException - Failed to copy file.public static void copy(URL src, File dest) throws IOException
src - the remote or local URLdest - the local fileIOException - upon errorpublic static String encodeFileName(String name)
name - the filename to encodepublic static String decodeFileName(String name)
name - the filename to decodepublic static String encodeFileName(String name, char escape)
name - the filename to encodeescape - the escape character to usepublic static String decodeFileName(String name, char escape)
name - the filename to decodeescape - the escape character to usepublic static String findRelativePath(String base, String path) throws IOException
base - - the path used as the basepath - - the path to compute relative to the base pathIOExceptionCopyright © 2015 JBoss by Red Hat. All rights reserved.