public class FileUtils extends Object
| 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).
|
static int |
FILECHANNEL_FILE_SIZE_THRESHOLD |
The minimum filesize at which it becomes more efficient to read a file with a memory-mapped file channel
rather than an InputStream.
|
| Constructor | Description |
|---|---|
FileUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static InputStream |
byteBufferToInputStream(ByteBuffer byteBuffer) |
Produce an
InputStream that is able to read from a ByteBuffer. |
static boolean |
canRead(File file) |
|
static boolean |
isClassfile(String path) |
|
static byte[] |
readAllBytesAsArray(InputStream inputStream,
long fileSize,
LogNode log) |
Read all the bytes in an
InputStream as a byte array. |
static String |
readAllBytesAsString(InputStream inputStream,
long fileSize,
LogNode log) |
Read all the bytes in an
InputStream as a String. |
public static final String CURR_DIR_PATH
public static final int FILECHANNEL_FILE_SIZE_THRESHOLD
public static byte[] readAllBytesAsArray(InputStream inputStream, long fileSize, LogNode log) throws IOException
InputStream as a byte array.inputStream - The InputStream.fileSize - The file size, if known, otherwise -1L.log - The log.InputStream as a byte array.IOException - If the contents could not be read.public static String readAllBytesAsString(InputStream inputStream, long fileSize, LogNode log) throws IOException
InputStream as a String.inputStream - The InputStream.fileSize - The file size, if known, otherwise -1L.log - The log.InputStream as a String.IOException - If the contents could not be read.public static InputStream byteBufferToInputStream(ByteBuffer byteBuffer)
InputStream that is able to read from a ByteBuffer.byteBuffer - The ByteBuffer.InputStream that reads from the ByteBuffer.public static boolean isClassfile(String path)
path - A file path.Copyright © 2018. All rights reserved.