public final class Files extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
BUFF_SIZE |
static String |
CURRENT_PATH |
static Charset |
DEFAULT_CHARSET |
static String |
DEFAULT_CHARSET_NAME |
static int |
EOF |
static String |
MAC_LINE_SEPARATOR |
static String |
SYSTEM_FOLDER_SEPARATOR |
static String |
SYSTEM_LINE_SEPARATOR |
static String |
TOP_PATH |
static String |
UNIX_FOLDER_SEPARATOR |
static String |
UNIX_LINE_SEPARATOR |
static String |
UTF_8 |
static String |
WINDOWS_FOLDER_SEPARATOR |
static String |
WINDOWS_LINE_SEPARATOR |
| 构造器和说明 |
|---|
Files() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Charset |
charset(String charsetName) |
static void |
cleanOrMakeDir(File path)
Clear or make directory
|
static File |
cleanOrMakeDir(String path)
Clear or make directory
|
static String |
cleanPath(String path)
文件路径规范化,如“path/..”内部的点号
注意:windows的文件分隔符“\”会替换为“/”
|
static void |
mkdirIfNotExists(File path)
Creates directory if not exists
|
static File |
mkdirIfNotExists(String path)
Creates directory if not exists
|
static Document |
parseToXmlDocument(InputStream inputStream) |
static byte[] |
readByteArray(File file,
int count) |
static byte[] |
readByteArray(InputStream input,
int count) |
static byte[] |
readByteArray(String filePath,
int count) |
static List<String> |
readLines(File file,
String charset) |
static List<String> |
readLines(InputStream input,
String charset) |
static void |
readLines(InputStream input,
String charset,
Consumer<String> consumer)
Read input-stream as text line
|
static String |
tmpDir() |
static byte[] |
toByteArray(File file)
Reads file to byte array
|
static File |
toFile(URL url) |
static String |
toString(File file) |
static String |
toString(File file,
Charset charset) |
static String |
toString(File file,
String charsetName) |
static String |
toString(String file) |
static void |
touchIfNotExists(File path)
Creates file if not exists
|
static File |
touchIfNotExists(String path)
Creates file if not exists
|
public static final int EOF
public static final int BUFF_SIZE
public static final Charset DEFAULT_CHARSET
public static final String DEFAULT_CHARSET_NAME
public static final String SYSTEM_FOLDER_SEPARATOR
public static final String SYSTEM_LINE_SEPARATOR
public static String tmpDir()
public static File mkdirIfNotExists(String path) throws IOException
path - the pathIOException - if create failedpublic static void mkdirIfNotExists(File path) throws IOException
path - the pathIOException - if create failedpublic static File cleanOrMakeDir(String path) throws IOException
path - the pathIOException - if clean or make failedpublic static void cleanOrMakeDir(File path) throws IOException
path - the pathIOException - if clean or make failedpublic static File touchIfNotExists(String path) throws IOException
path - the pathIOException - if create failedpublic static void touchIfNotExists(File path) throws IOException
path - the pathIOException - if create failedpublic static byte[] toByteArray(File file)
file - the filepublic static List<String> readLines(File file, String charset) throws FileNotFoundException
public static List<String> readLines(InputStream input, String charset)
public static void readLines(InputStream input, String charset, Consumer<String> consumer)
input - the input streamcharset - the charsetconsumer - the consumerpublic static byte[] readByteArray(InputStream input, int count) throws IOException
IOExceptionpublic static byte[] readByteArray(File file, int count) throws IOException
IOExceptionpublic static byte[] readByteArray(String filePath, int count) throws IOException
IOExceptionpublic static String cleanPath(String path)
path - 文件路径public static Document parseToXmlDocument(InputStream inputStream) throws Exception
ExceptionCopyright © 2025. All rights reserved.