public class FileUtils extends Object
| 构造器和说明 |
|---|
FileUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
cleanDirectory(File directory) |
static void |
closeQuietly(Closeable closeable) |
static void |
deleteDirectory(File directory) |
static void |
forceDelete(File file) |
static void |
forceMkdir(File directory)
create dir
|
static FileInputStream |
openInputStream(File file)
file to inputStream
|
static FileOutputStream |
openOutputStream(File file,
boolean append)
file output stream
|
static byte[] |
readFileToByteArray(File file)
read file
|
static byte[] |
toByteArray(InputStream input,
int size)
transfer InputStream to byteArray
|
static byte[] |
toByteArray(InputStream input,
long size)
transfer InputStream to byteArray
|
static void |
writeByteArrayToFile(File file,
byte[] data,
boolean append)
write file
|
public static void writeByteArrayToFile(File file, byte[] data, boolean append) throws IOException
file - filedata - dataappend - appendIOException - IOExceptionpublic static byte[] readFileToByteArray(File file) throws IOException
file - fileIOException - IOExceptionpublic static void forceMkdir(File directory) throws IOException
directory - directoryIOException - IOExceptionpublic static FileOutputStream openOutputStream(File file, boolean append) throws IOException
file - fileappend - appendIOException - IOExceptionpublic static FileInputStream openInputStream(File file) throws IOException
file - fileIOException - IOExceptionpublic static byte[] toByteArray(InputStream input, long size) throws IOException
input - inputsize - sizeIOException - IOExceptionpublic static byte[] toByteArray(InputStream input, int size) throws IOException
input - inputsize - sizeIOException - IOExceptionpublic static void closeQuietly(Closeable closeable)
closeable - closeablepublic static void forceDelete(File file) throws IOException
IOExceptionpublic static void deleteDirectory(File directory) throws IOException
IOExceptionpublic static void cleanDirectory(File directory) throws IOException
IOExceptionCopyright © 2023 The Ant Financial. All rights reserved.