public class FileUtils extends Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(InputStream input)
Unconditionally close an
InputStream. |
static void |
closeQuietly(OutputStream output)
Unconditionally close an
OutputStream. |
static int |
copy(InputStream input,
OutputStream output)
Copy bytes from an
InputStream to an
OutputStream. |
static void |
copyDirectory(File srcDir,
File destDir)
Copies a whole directory to a new location preserving the file dates.
|
static void |
copyDirectory(File srcDir,
File destDir,
boolean preserveFileDate)
Copies a whole directory to a new location.
|
static void |
copyFile(File srcFile,
File destFile,
boolean preserveFileDate)
Copy file method.
|
static boolean |
deleteDir(File dir)
Deletes all files and subdirectories under dir.
|
static File |
getFile(File parentFile,
String fileName) |
static Map<String,String> |
readJarsWithMD5(BufferedReader bufferedReader) |
static List<String> |
readLinesToList(BufferedReader bufferedReader) |
public static void copyDirectory(File srcDir, File destDir) throws IOException
srcDir - an existing directory to copy, must not be nulldestDir - the new directory, must not be nullNullPointerException - if source or destination is nullIOException - if source or destination is invalidpublic static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) throws IOException
srcDir - an existing directory to copy, must not be nulldestDir - the new directory, must not be nullpreserveFileDate - true if the file date of the copy
should be the same as the originalNullPointerException - if source or destination is nullIOException - if source or destination is invalidpublic static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException
srcFile - the validated source file, not nulldestFile - the validated destination file, not nullpreserveFileDate - whether to preserve the file dateIOException - if an error occurspublic static void closeQuietly(OutputStream output)
OutputStream.
Equivalent to OutputStream.close(), except any exceptions will be ignored.
This is typically used in finally blocks.output - the OutputStream to close, may be null or already closedpublic static void closeQuietly(InputStream input)
InputStream.
Equivalent to InputStream.close(), except any exceptions will be ignored.
This is typically used in finally blocks.input - the InputStream to close, may be null or already closedpublic static int copy(InputStream input, OutputStream output) throws IOException
InputStream to an
OutputStream.
This method buffers the input internally, so there is no need to use a
BufferedInputStream.input - the InputStream to read fromoutput - the OutputStream to write toNullPointerException - if the input or output is nullIOException - if an I/O error occurspublic static boolean deleteDir(File dir)
dir - The directory to be deletedpublic static List<String> readLinesToList(BufferedReader bufferedReader) throws IOException
IOExceptionpublic static Map<String,String> readJarsWithMD5(BufferedReader bufferedReader) throws IOException
IOExceptionCopyright © 2018 WSO2 Inc. All rights reserved.