public class Files
extends java.lang.Object
Constructor and Description |
---|
Files() |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
backup(java.io.File file,
boolean copy)
Backup the given file to a new file called <file-name>~.
|
static boolean |
copy(java.io.File from,
java.io.File to)
Copy a file.
|
static java.io.File |
getClassFile(java.lang.Class cls)
Return the class file of the given class, or null if the
class is in a jar.
|
static java.io.File |
getFile(java.lang.String name,
java.lang.ClassLoader loader)
Check the given string for a matching file.
|
static java.io.OutputStream |
getOutputStream(java.lang.String file,
java.lang.ClassLoader loader)
Return an output stream to the stream(stdout or stderr) or file named
by the given string.
|
static java.io.File |
getPackageFile(java.io.File base,
java.lang.String pkg,
boolean mkdirs)
Return the file for the given package.
|
static java.io.File |
getSourceFile(java.lang.Class cls)
Return the source file for the given class, or null if the
source is not in the CLASSPATH.
|
static java.io.Writer |
getWriter(java.lang.String file,
java.lang.ClassLoader loader)
Return a writer to the stream(stdout or stderr) or file named by the
given string.
|
static java.io.File |
revert(java.io.File backup,
boolean copy)
Revert the given backup file to the original location.
|
public static java.io.File backup(java.io.File file, boolean copy)
public static java.io.File revert(java.io.File backup, boolean copy)
public static java.io.File getSourceFile(java.lang.Class cls)
public static java.io.File getClassFile(java.lang.Class cls)
public static java.io.File getPackageFile(java.io.File base, java.lang.String pkg, boolean mkdirs)
public static java.io.File getFile(java.lang.String name, java.lang.ClassLoader loader)
name
- the file path or resource nameloader
- a class loader to use in resource lookup, or null
to use the thread's context loaderpublic static java.io.Writer getWriter(java.lang.String file, java.lang.ClassLoader loader) throws java.io.IOException
java.io.IOException
getFile(java.lang.String, java.lang.ClassLoader)
public static java.io.OutputStream getOutputStream(java.lang.String file, java.lang.ClassLoader loader)
public static boolean copy(java.io.File from, java.io.File to) throws java.io.IOException
from
does not exist.java.io.IOException