public class FileUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EX_CACHE |
static String |
POI_FILES |
| Modifier and Type | Method and Description |
|---|---|
static File |
createCacheTmpFile() |
static File |
createDirectory(File directory) |
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.
|
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
|
static void |
writeToFile(File file,
InputStream inputStream,
boolean closeInputStream)
Write inputStream to file
|
public static final String POI_FILES
public static final String EX_CACHE
public static byte[] readFileToByteArray(File file) throws IOException
file - IOExceptionpublic 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 - IOExceptionpublic static void writeToFile(File file, InputStream inputStream)
file - fileinputStream - inputStreampublic static void writeToFile(File file, InputStream inputStream, boolean closeInputStream)
file - fileinputStream - inputStreamcloseInputStream - closeInputStreampublic 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–2024 Alibaba Group. All rights reserved.