|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectml.shifu.guagua.util.FileUtils
public final class FileUtils
Copied from apache common-io source code.
| 字段摘要 | |
|---|---|
static char |
SYSTEM_SEPARATOR
The system separator character. |
static char |
UNIX_SEPARATOR
The Unix separator character. |
static char |
WINDOWS_SEPARATOR
The Windows separator character. |
| 方法摘要 | |
|---|---|
static void |
cleanDirectory(File directory)
Cleans a directory without deleting it. |
static void |
deleteDirectory(File directory)
Deletes a directory recursively. |
static boolean |
deleteQuietly(File file)
Deletes a file, never throwing an exception. |
static void |
forceDelete(File file)
Deletes a file. |
static void |
forceDeleteOnExit(File file)
Schedules a file to be deleted when JVM exits. |
static File |
getTempDirectory()
Returns a File representing the system temporary directory. |
static String |
getTempDirectoryPath()
Returns the path to the system temporary directory. |
static File |
getUserDirectory()
Returns a File representing the user's home directory. |
static String |
getUserDirectoryPath()
Returns the path to the user's home directory. |
static boolean |
isSymlink(File file)
Determines whether the specified file is a Symbolic Link rather than an actual file. |
static FileInputStream |
openInputStream(File file)
Opens a FileInputStream for the specified file, providing better
error messages than simply calling new FileInputStream(file). |
static List<String> |
readLines(File file)
Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. |
static List<String> |
readLines(File file,
String encoding)
Reads the contents of a file line by line to a List of Strings. |
static List<String> |
readLines(InputStream input)
Get the contents of an InputStream as a list of Strings,
one entry per line, using the default character encoding of the platform. |
static List<String> |
readLines(InputStream input,
String encoding)
Get the contents of an InputStream as a list of Strings,
one entry per line, using the specified character encoding. |
static List<String> |
readLines(Reader input)
Get the contents of a Reader as a list of Strings,
one entry per line. |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final char UNIX_SEPARATOR
public static final char WINDOWS_SEPARATOR
public static final char SYSTEM_SEPARATOR
| 方法详细信息 |
|---|
public static String getTempDirectoryPath()
public static File getTempDirectory()
File representing the system temporary directory.
public static String getUserDirectoryPath()
public static File getUserDirectory()
File representing the user's home directory.
public static void deleteDirectory(File directory)
throws IOException
directory - directory to delete
IOException - in case deletion is unsuccessfulpublic static boolean deleteQuietly(File file)
The difference between File.delete() and this method are:
file - file or directory to delete, can be null
true if the file or directory was deleted, otherwise false
public static void cleanDirectory(File directory)
throws IOException
directory - directory to clean
IOException - in case cleaning is unsuccessful
public static void forceDelete(File file)
throws IOException
The difference between File.delete() and this method are:
file - file or directory to delete, must not be null
NullPointerException - if the directory is null
FileNotFoundException - if the file was not found
IOException - in case deletion is unsuccessful
public static void forceDeleteOnExit(File file)
throws IOException
file - file or directory to delete, must not be null
NullPointerException - if the file is null
IOException - in case deletion is unsuccessful
public static boolean isSymlink(File file)
throws IOException
Will not return true if there is a Symbolic Link anywhere in the path, only if the specific file is.
file - the file to check
IOException - if an IO error occurs while checking the file
public static List<String> readLines(File file,
String encoding)
throws IOException
file - the file to read, must not be nullencoding - the encoding to use, null means platform default
null
IOException - in case of an I/O error
UnsupportedEncodingException - if the encoding is not supported by the VM
public static List<String> readLines(File file)
throws IOException
file - the file to read, must not be null
null
IOException - in case of an I/O error
public static List<String> readLines(InputStream input)
throws IOException
InputStream as a list of Strings,
one entry per line, using the default character encoding of the platform.
This method buffers the input internally, so there is no need to use a BufferedInputStream.
input - the InputStream to read from, not null
NullPointerException - if the input is null
IOException - if an I/O error occurs
public static List<String> readLines(InputStream input,
String encoding)
throws IOException
InputStream as a list of Strings,
one entry per line, using the specified character encoding.
Character encoding names can be found at IANA.
This method buffers the input internally, so there is no need to use a BufferedInputStream.
input - the InputStream to read from, not nullencoding - the encoding to use, null means platform default
NullPointerException - if the input is null
IOException - if an I/O error occurs
public static List<String> readLines(Reader input)
throws IOException
Reader as a list of Strings,
one entry per line.
This method buffers the input internally, so there is no need to use a BufferedReader.
input - the Reader to read from, not null
NullPointerException - if the input is null
IOException - if an I/O error occurs
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 - the file to open for input, must not be null
FileInputStream for the specified file
FileNotFoundException - if the file does not exist
IOException - if the file object is a directory
IOException - if the file cannot be read
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||