public class FileUtils extends Object
限定符和类型 | 方法和说明 |
---|---|
static File |
createCacheTmpFile() |
static void |
createPoiFilesDirectory() |
static File |
createTmpFile(String fileName) |
static void |
delete(File file)
delete file
|
static String |
getCachePath() |
static String |
getPoiFilesPath() |
static String |
getTempFilePrefix() |
static FileInputStream |
openInputStream(File file)
Opens a
FileInputStream for the specified file, providing better error messages than simply calling
new FileInputStream(file) . |
static byte[] |
readFileToByteArray(File file)
Reads the contents of a file into a byte array. * The file is always closed.
|
static void |
setCachePath(String cachePath) |
static void |
setPoiFilesPath(String poiFilesPath) |
static void |
setTempFilePrefix(String tempFilePrefix) |
static void |
writeToFile(File file,
InputStream inputStream)
Write inputStream to file
|
public static byte[] readFileToByteArray(File file) throws IOException
file
- IOException
public static FileInputStream openInputStream(File file) throws IOException
FileInputStream
for the specified file, providing better error messages than simply calling
new FileInputStream(file)
.
At the end of the method either the stream will be successfully opened, or an exception will have been thrown.
An exception is thrown if the file does not exist. An exception is thrown if the file object exists but is a directory. An exception is thrown if the file exists but cannot be read.
file
- IOException
public static void writeToFile(File file, InputStream inputStream)
file
- inputStream
- public static void createPoiFilesDirectory()
public static File createCacheTmpFile()
public static void delete(File file)
file
- public static String getTempFilePrefix()
public static void setTempFilePrefix(String tempFilePrefix)
public static String getPoiFilesPath()
public static void setPoiFilesPath(String poiFilesPath)
public static String getCachePath()
public static void setCachePath(String cachePath)
Copyright © 2018–2021 Alibaba Group. All rights reserved.