Class FileUtils
- java.lang.Object
-
- io.github.fastclasspathscanner.utils.FileUtils
-
public class FileUtils extends Object
File utilities.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CURR_DIR_PATH
The current directory path (only reads the current directory once, the first time this field is accessed, so will not reflect subsequent changes to the current directory).
-
Constructor Summary
Constructors Constructor Description FileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InputStream
byteBufferToInputStream(ByteBuffer byteBuffer)
Produce anInputStream
that is able to read from aByteBuffer
.static boolean
isClassfile(String path)
static byte[]
readAllBytes(InputStream inputStream, long fileSize, LogNode log)
Read all the bytes in anInputStream
.
-
-
-
Field Detail
-
CURR_DIR_PATH
public static final String CURR_DIR_PATH
The current directory path (only reads the current directory once, the first time this field is accessed, so will not reflect subsequent changes to the current directory).
-
-
Method Detail
-
readAllBytes
public static byte[] readAllBytes(InputStream inputStream, long fileSize, LogNode log) throws IOException
Read all the bytes in anInputStream
.- Parameters:
inputStream
- TheInputStream
.fileSize
- The file size, if known, otherwise -1L.log
- The log.- Returns:
- The contents of the
InputStream
. - Throws:
IOException
- If the contents could not be read.
-
isClassfile
public static boolean isClassfile(String path)
- Parameters:
path
- A file path.- Returns:
- true if path has a ".class" extension, ignoring case.
-
byteBufferToInputStream
public static InputStream byteBufferToInputStream(ByteBuffer byteBuffer)
Produce anInputStream
that is able to read from aByteBuffer
.- Parameters:
byteBuffer
- TheByteBuffer
.- Returns:
- An
InputStream
that reads from the .
-
-