Package org.wso2.carbon.server.util
Class FileUtils
java.lang.Object
org.wso2.carbon.server.util.FileUtils
taken from the commons file utils class. we didnt want to use the library. hence copied the source
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseQuietly(InputStream input) Unconditionally close anInputStream.static voidcloseQuietly(OutputStream output) Unconditionally close anOutputStream.static intcopy(InputStream input, OutputStream output) Copy bytes from anInputStreamto anOutputStream.static voidcopyDirectory(File srcDir, File destDir) Copies a whole directory to a new location preserving the file dates.static voidcopyDirectory(File srcDir, File destDir, boolean preserveFileDate) Copies a whole directory to a new location.static voidCopy file method.static booleanDeletes all files and subdirectories under dir.static FileReturn the file when filename and parent file is givenreadJarsWithMD5(BufferedReader bufferedReader) readLinesToList(BufferedReader bufferedReader)
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
copyDirectory
Copies a whole directory to a new location preserving the file dates. This method copies the specified directory and all its child directories and files to the specified destination. The destination is the new location and name of the directory. The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.- Parameters:
srcDir- an existing directory to copy, must not be nulldestDir- the new directory, must not be null- Throws:
NullPointerException- if source or destination is nullIOException- if source or destination is invalid- Since:
- Commons IO 1.1
-
copyDirectory
public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) throws IOException Copies a whole directory to a new location. This method copies the contents of the specified source directory to within the specified destination directory. The destination directory is created if it does not exist. If the destination directory did exist, then this method merges the source with the destination, with the source taking precedence.- Parameters:
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 original- Throws:
NullPointerException- if source or destination is nullIOException- if source or destination is invalid- Since:
- Commons IO 1.1
-
copyFile
public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException Copy file method.- Parameters:
srcFile- the validated source file, not nulldestFile- the validated destination file, not nullpreserveFileDate- whether to preserve the file date- Throws:
IOException- if an error occurs
-
closeQuietly
Unconditionally close anOutputStream. Equivalent toOutputStream.close(), except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
output- the OutputStream to close, may be null or already closed
-
closeQuietly
Unconditionally close anInputStream. Equivalent toInputStream.close(), except any exceptions will be ignored. This is typically used in finally blocks.- Parameters:
input- the InputStream to close, may be null or already closed
-
copy
Copy bytes from anInputStreamto anOutputStream. This method buffers the input internally, so there is no need to use aBufferedInputStream.- Parameters:
input- theInputStreamto read fromoutput- theOutputStreamto write to- Returns:
- the number of bytes copied
- Throws:
NullPointerException- if the input or output is nullIOException- if an I/O error occurs- Since:
- Commons IO 1.1
-
deleteDir
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.- Parameters:
dir- The directory to be deleted- Returns:
- true if the directory and its descendents were deleted
-
getFile
Return the file when filename and parent file is given- Parameters:
parentFile- parent filefileName- the name of the file- Returns:
- File
-
readLinesToList
- Throws:
IOException
-
readJarsWithMD5
- Throws:
IOException
-