public class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
cp(File src,
File dest)
Copies a file
src to the dest. |
static void |
cp(InputStream is,
File dest)
Copies the content of the input stream within the given dest file.
|
static void |
dumpContent(File f,
String content)
Dumps the given string within a file.
|
static void |
dumpContent(File f,
Throwable t)
Dumps the stack trace of the given exception into the specified file.
|
static File[] |
listFilesRecursively(File dir,
FilenameFilter filenameFilter)
Lists the content of a dir applying the specified filter.
|
static File |
mv(File target,
File dest)
Moves a
target file to a new dest location. |
static String |
readFileContent(File f)
Returns the content of a file a single string.
|
static String[] |
readFileLines(File f)
Returns all the lines of a file.
|
static String |
readResourceContent(Class clazz,
String resource)
Reads a resource file and returns the content as a string.
|
static String |
readResourceContent(String resource)
Reads a resource file and returns the content as a string.
|
public static File mv(File target, File dest)
target file to a new dest location.target - file to be moved.dest - dest dir.public static void cp(InputStream is, File dest)
is - dest - public static void cp(File src, File dest) throws FileNotFoundException
src to the dest.src - source file.dest - destination file.FileNotFoundException - if file cannot be copied or created.public static void dumpContent(File f, String content) throws IOException
f - file target.content - content to be dumped.IOExceptionpublic static void dumpContent(File f, Throwable t) throws IOException
f - file to generate dump.t - exception to be dumped.IOExceptionpublic static String readResourceContent(Class clazz, String resource) throws IOException
clazz - the class to use load the resource.resource - the resource to be load.IOExceptionpublic static String readResourceContent(String resource) throws IOException
resource - the resource to be load.IOExceptionpublic static String readFileContent(File f) throws IOException
f - the file to read.IOException - if an error occurs while locating or accessing the file.public static String[] readFileLines(File f) throws IOException
f - the file to read.null array with not null line strings.IOException - if an error occurs while locating or accessing the file.public static File[] listFilesRecursively(File dir, FilenameFilter filenameFilter)
dir - directory root.filenameFilter - filter to be applied.Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.