public class FileTool extends Object
| 构造器和说明 |
|---|
FileTool() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
appendFile(String f,
String d)
在文件中追加
|
static void |
appendFile(String f,
String d,
String charset)
在文件中追加
|
static void |
copy(String source,
String dest) |
static boolean |
delFile(String f)
删除文件
|
static void |
delPath(String filepath) |
static boolean |
exists(String filename)
判断文件是否存在
|
static String |
getParentDir(String d)
获取父文件夹
|
static long |
lastModify(String fn) |
static ArrayList<Double> |
loadBinMatrix(String file) |
static ArrayList<Double> |
loadTextMatrix(String filename) |
static void |
makeDir(String d)
创建文件夹
|
static void |
printHashMap(HashMap<?,?> hm) |
static String |
readAll(InputStream in,
String charset)
根据输入流进行读取。
|
static String |
readAll(String f,
String charset)
读取文件内容,给定编码方式
|
static String |
readAllCRLF(String f)
读取文件中所有的内容,编码方式为GB2312 ,行为补充\r\n
该函数已过期
|
static byte[] |
readBytes(String filename)
读取文件中所有的字节
|
static String[] |
readLines(String filename,
String charset) |
static String |
readResource(String fname,
String charset)
读取资源
|
static void |
safelyClose(AutoCloseable obj) |
static void |
safelyClose(Closeable out) |
static void |
saveBinMatrix(String file,
ArrayList<?> al) |
static void |
touch(String f) |
static void |
writeAll(InputStream in,
OutputStream os) |
static void |
writeAll(OutputStream os,
String data,
String charset) |
static void |
writeAll(String f,
String data)
已过时。
|
static void |
writeAll(String f,
String data,
String charset)
将所有内容写入文件中
|
static void |
writeUTF(String f,
String data)
以utf-8编码进行写文件
|
static void |
writeUTFOLD(String f,
String data)
已过时。
|
public static void safelyClose(Closeable out)
public static byte[] readBytes(String filename)
filename - 文件名public static String readAllCRLF(String f)
f - 文件名public static String readAll(String f, String charset)
f - 文件名或路径charset - 文件编码方式public static String readAll(InputStream in, String charset)
in - 输入流charset - 字符集@Deprecated public static void writeUTFOLD(String f, String data)
public static void writeAll(String f, String data, String charset)
f - 文件路径data - 待写入内容charset - 编码方式@Deprecated public static void writeAll(String f, String data)
public static void makeDir(String d)
d - 路径public static void appendFile(String f, String d, String charset)
f - 文件名d - 内容charset - 编码public static boolean delFile(String f)
f - 文件名public static boolean exists(String filename)
filename - 文件路径public static long lastModify(String fn)
public static void printHashMap(HashMap<?,?> hm)
public static void touch(String f)
public static void delPath(String filepath)
public static String readResource(String fname, String charset)
fname - 相对根目录的文件名charset - 文件编码方式public static void writeAll(OutputStream os, String data, String charset)
public static void writeAll(InputStream in, OutputStream os)
public static void safelyClose(AutoCloseable obj)
Copyright © 2023. All rights reserved.