public class FileUtils extends Object
| 构造器和说明 |
|---|
FileUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static FileInputStream |
openInputStream(File file)
Opens a
FileInputStream for the specified file, providing better error messages than simply calling new
FileInputStream(file). |
static String |
readFileToString(File file)
已过时。
2.5 use
readFileToString(File, Charset) instead |
static String |
readFileToString(File file,
Charset encoding)
Reads the contents of a file into a String.
|
@Deprecated public static String readFileToString(File file) throws IOException
readFileToString(File, Charset) insteadfile - the file to read, must not be nullnullIOException - in case of an I/O errorpublic static String readFileToString(File file, Charset encoding) throws IOException
file - the file to read, must not be nullencoding - the encoding to use, null means platform defaultnullIOException - in case of an I/O errorpublic 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 - the file to open for input, must not be nullFileInputStream for the specified fileFileNotFoundException - if the file does not existIOException - if the file object is a directoryIOException - if the file cannot be readCopyright © 2020. All rights reserved.