Class FileUtils
- java.lang.Object
-
- com.github.nosan.embedded.cassandra.commons.FileUtils
-
public final class FileUtils extends Object
Simple utility methods for dealing with files and directories.- Since:
- 4.0.0
- Author:
- Dmytro Nosan
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringchecksum(Path file, String algorithm)Computes the checksum of the file using the provided algorithm.static voidcopy(Path src, Path dest, CopyOption... options)Copies a path to a target path.static voidcopy(Path src, Path dest, BiPredicate<? super Path,? super BasicFileAttributes> filter, CopyOption... options)Copies a path to a target path.static booleandelete(Path path)Deletes the suppliedPath.
-
-
-
Method Detail
-
delete
public static boolean delete(Path path) throws IOException
Deletes the suppliedPath. For directories, recursively delete any nested directories or files as well.- Parameters:
path- thepathto delete- Returns:
trueif thepathexisted and was deleted, orfalseit did not exist- Throws:
IOException- in the case of I/O errors
-
copy
public static void copy(Path src, Path dest, CopyOption... options) throws IOException
Copies a path to a target path. For directories, it will be copied recursively.- Parameters:
src- the source pathdest- the destination pathoptions- specifying how the copy should be done the path to the target file- Throws:
IOException- in the case of I/O errors
-
copy
public static void copy(Path src, Path dest, BiPredicate<? super Path,? super BasicFileAttributes> filter, CopyOption... options) throws IOException
Copies a path to a target path. For directories, it will be copied recursively.- Parameters:
src- the source pathdest- the destination pathoptions- specifying how the copy should be done the path to the target filefilter- the function used to decide whether a path should be copied or not- Throws:
IOException- in the case of I/O errors
-
checksum
public static String checksum(Path file, String algorithm) throws NoSuchAlgorithmException, IOException
Computes the checksum of the file using the provided algorithm.- Parameters:
file- the file to readalgorithm- the name of the algorithm.- Returns:
- the computed checksum in lowercase hex format
- Throws:
NoSuchAlgorithmException- if no Provider supports a MessageDigestSpi implementation for the specified algorithm.IOException- in the case of I/O errors
-
-