package Test;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
public class File {
public static String encoding = "UTF-8";
public static String read(String path){
StringBuffer buf = new StringBuffer();
try {
FileInputStream in = new FileInputStream(path);
// 指定读取文件时以UTF-8的格式读取
BufferedReader br = new BufferedReader(new UnicodeReader(in, encoding));
String line = br.readLine();
while (line != null) {
buf.append(line);
line = br.readLine();
}
} catch (Exception e) {
e.printStackTrace();
}
return buf.toString();
}
public static void write(String path, String content){
try
{
OutputStreamWriter out = new OutputStreamWriter(
new FileOutputStream(path),"UTF-8");
//out.write("\n"+content);
out.write(content);
out.flush();
out.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
public static String getFileName(String fileName){
String[] ss = fileName.split(".");
fileName = ss[0];
String[] ss2 = fileName.split("/");
fileName = ss[ss.length-1];
return fileName;
}
}
最近下载更多
wusiyin LV14
2022年9月15日
askeydingxu2020 LV8
2020年11月28日
skipple3 LV39
2020年11月19日
xcj456 LV8
2020年9月12日
hzhsh0223 LV18
2020年3月7日
yfsh123 LV6
2019年8月9日
y_yuyongyi LV1
2019年8月7日
wanglong_wang LV13
2019年8月1日
zbchen2008 LV6
2019年7月9日
丷夏空丷 LV4
2019年5月19日

最近浏览