public class Resourcer extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
TEMP_FOLDER |
| 构造器和说明 |
|---|
Resourcer() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
clean_folder(File file) |
static void |
copy_file_to_folder(File srcfile,
File folder) |
static void |
copy_file_to_stream(File srcfile,
OutputStream os)
将文件写入输出流
|
static void |
copy_folder_to_folder(File srcfolder,
File folder) |
static void |
delete(File file) |
static File |
getTempDir(boolean usesys)
查询应用临时目录
|
static String |
getUserRootDir()
查询应用运行目录
|
static void |
mkdir_folder(File file) |
static void |
move_file_to_folder(File srcfile,
File folder) |
static void |
move_folder_to_folder(File srcfolder,
File folder) |
static byte[] |
read_bytes(File file)
读取文件内容
|
static org.apache.commons.io.LineIterator |
read_line_iterator(File file,
String encoding)
按行读取文件内容
|
static List<String> |
read_lines(File file,
String encoding)
按行读取文件内容
|
static String |
read_string(File file,
String encoding)
读取文件内容
|
static byte[] |
to_bytes(InputStream is) |
static byte[] |
to_bytes(InputStream is,
long size) |
static byte[] |
to_bytes(Reader reader) |
static byte[] |
to_bytes(URI uri) |
static byte[] |
to_bytes(URL url) |
static String |
to_string(byte[] bytes,
String encoding) |
static String |
to_string(InputStream is,
String encoding) |
static String |
to_string(Reader reader) |
static String |
to_string(URI uri,
String encoding) |
static String |
to_string(URL url,
String encoding) |
static void |
write_bytes(File file,
byte[] data,
boolean append)
向文件写入二进制
|
static void |
write_stream(File file,
InputStream is)
向文件写入输入流
|
static void |
write_string(File file,
String data,
String encoding,
boolean append)
向文件写入字符串
|
static void |
write_url(File file,
String url,
int conntimeout,
int readtimeout)
向文件写入网络资源内容
|
public static String read_string(File file, String encoding) throws IOException
file - 文件encoding - 编码IOExceptionpublic static byte[] read_bytes(File file) throws IOException
file - 文件IOExceptionpublic static List<String> read_lines(File file, String encoding) throws IOException
file - 文件encoding - 指定编码IOExceptionpublic static org.apache.commons.io.LineIterator read_line_iterator(File file, String encoding) throws IOException
file - 文件encoding - 指定编码IOExceptionpublic static void write_string(File file, String data, String encoding, boolean append) throws IOException
file - 文件data - 内容encoding - 编码append - 是否追加IOExceptionpublic static void write_bytes(File file, byte[] data, boolean append) throws IOException
file - 文件data - 内容append - 是否追加IOExceptionpublic static void write_url(File file, String url, int conntimeout, int readtimeout) throws IOException
file - 文件url - 网络资源conntimeout - 连接超时时间readtimeout - 读取超时时间IOExceptionpublic static void write_stream(File file, InputStream is) throws IOException
file - 文件is - 输入流IOExceptionpublic static void copy_file_to_folder(File srcfile, File folder) throws IOException
IOExceptionpublic static void copy_folder_to_folder(File srcfolder, File folder) throws IOException
IOExceptionpublic static void move_file_to_folder(File srcfile, File folder) throws IOException
IOExceptionpublic static void move_folder_to_folder(File srcfolder, File folder) throws IOException
IOExceptionpublic static void copy_file_to_stream(File srcfile, OutputStream os) throws IOException
srcfile - 文件os - 输出流IOExceptionpublic static void delete(File file) throws IOException
IOExceptionpublic static void clean_folder(File file) throws IOException
IOExceptionpublic static void mkdir_folder(File file) throws IOException
IOExceptionpublic static byte[] to_bytes(InputStream is) throws IOException
IOExceptionpublic static byte[] to_bytes(InputStream is, long size) throws IOException
IOExceptionpublic static byte[] to_bytes(Reader reader) throws IOException
IOExceptionpublic static byte[] to_bytes(URL url) throws IOException
IOExceptionpublic static byte[] to_bytes(URI uri) throws IOException
IOExceptionpublic static String to_string(byte[] bytes, String encoding) throws IOException
IOExceptionpublic static String to_string(InputStream is, String encoding) throws IOException
IOExceptionpublic static String to_string(Reader reader) throws IOException
IOExceptionpublic static String to_string(URL url, String encoding) throws IOException
IOExceptionpublic static String to_string(URI uri, String encoding) throws IOException
IOExceptionpublic static String getUserRootDir()
public static File getTempDir(boolean usesys)
usesys - 是否使用系统临时目录Copyright (c) 2002-2020 Luther Inc.