Class FileUtils
java.lang.Object
org.owasp.dependencycheck.utils.FileUtils
A collection of utilities for processing information about files.
- Author:
- Jeremy Long
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidClose the givenCloseableinstance, ignoring nulls, and logging any thrownIOException.static @NonNull FilecreateTempDirectory(@Nullable File base) Creates a unique temporary directory in the given directory.static booleanDeletes a file.static @NonNull StringReturn the bit bucket for the OS.static @Nullable StringgetFileExtension(@NonNull String fileName) Returns the (lowercase) file extension for a specified file.static FilegetResourceAsFile(String resource) Returns a File object for the given resource.static InputStreamgetResourceAsStream(@NonNull String resource) Gets theInputStreamfor this resource.
-
Method Details
-
getFileExtension
-
delete
Deletes a file. If the File is a directory it will recursively delete the contents.- Parameters:
file- the File to delete- Returns:
- true if the file was deleted successfully, otherwise false
-
createTempDirectory
Creates a unique temporary directory in the given directory.- Parameters:
base- the base directory to create a temporary directory within- Returns:
- the temporary directory
- Throws:
IOException- thrown when a directory cannot be created within the base directory
-
getBitBucket
Return the bit bucket for the OS. '/dev/null' for Unix and 'NUL' for Windows- Returns:
- a String containing the bit bucket
-
close
Close the givenCloseableinstance, ignoring nulls, and logging any thrownIOException.- Parameters:
closeable- to be closed
-
getResourceAsStream
public static InputStream getResourceAsStream(@NonNull String resource) throws FileNotFoundException Gets theInputStreamfor this resource.- Parameters:
resource- path- Returns:
- the input stream for the given resource
- Throws:
FileNotFoundException- if the file could not be found
-
getResourceAsFile
-