com.alibaba.excel.util
类 FileUtils
- java.lang.Object
-
- com.alibaba.excel.util.FileUtils
public class FileUtils extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.- 作者:
- Apache Software Foundation (ASF)
-
方法概要
所有方法 静态方法 具体方法 限定符和类型 方法和说明 static File
createCacheTmpFile()
static void
createPoiFilesDirectory()
static File
createTmpFile(String fileName)
static void
delete(File file)
delete filestatic String
getCachePath()
static String
getPoiFilesPath()
static String
getTempFilePrefix()
static FileInputStream
openInputStream(File file)
Opens aFileInputStream
for the specified file, providing better error messages than simply callingnew 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 filestatic void
writeToFile(File file, InputStream inputStream, boolean closeInputStream)
Write inputStream to file
-
方法详细资料
readFileToByteArray
public static byte[] readFileToByteArray(File file) throws IOException
Reads the contents of a file into a byte array. * The file is always closed.- 参数:
-
file
- - 返回:
- 抛出:
-
IOException
openInputStream
public static FileInputStream openInputStream(File file) throws IOException
Opens aFileInputStream
for the specified file, providing better error messages than simply callingnew 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
writeToFile
public static void writeToFile(File file, InputStream inputStream)
Write inputStream to file- 参数:
-
file
- file -
inputStream
- inputStream
writeToFile
public static void writeToFile(File file, InputStream inputStream, boolean closeInputStream)
Write inputStream to file- 参数:
-
file
- file -
inputStream
- inputStream -
closeInputStream
- closeInputStream
createPoiFilesDirectory
public static void createPoiFilesDirectory()
createCacheTmpFile
public static File createCacheTmpFile()
delete
public static void delete(File file)
delete file- 参数:
-
file
-
getTempFilePrefix
public static String getTempFilePrefix()
setTempFilePrefix
public static void setTempFilePrefix(String tempFilePrefix)
getPoiFilesPath
public static String getPoiFilesPath()
setPoiFilesPath
public static void setPoiFilesPath(String poiFilesPath)
getCachePath
public static String getCachePath()
setCachePath
public static void setCachePath(String cachePath)
Copyright © 2018–2021 Alibaba Group. All rights reserved.