01 | package Test; |
02 |
03 | import java.io.*; |
04 | import java.nio.charset.Charset; |
05 | import java.util.ArrayList; |
06 | import java.util.List; |
07 |
08 | public class File { |
09 | public static String encoding = "UTF-8" ; |
10 | public static String read(String path){ |
11 | StringBuffer buf = new StringBuffer(); |
12 | try { |
13 | FileInputStream in = new FileInputStream(path); |
14 | // 指定读取文件时以UTF-8的格式读取 |
15 | BufferedReader br = new BufferedReader( new UnicodeReader(in, encoding)); |
16 | String line = br.readLine(); |
17 | while (line != null ) { |
18 | buf.append(line); |
19 | line = br.readLine(); |
20 | } |
21 | } catch (Exception e) { |
22 | e.printStackTrace(); |
23 | } |
24 | return buf.toString(); |
25 | } |
26 | public static void write(String path, String content){ |
27 | try |
28 | { |
29 | OutputStreamWriter out = new OutputStreamWriter( |
30 | new FileOutputStream(path), "UTF-8" ); |
31 | //out.write("\n"+content); |
32 | out.write(content); |
33 | out.flush(); |
34 | out.close(); |
35 | } |
36 | catch (IOException e) |
37 | { |
38 | e.printStackTrace(); |
39 | } |
40 | } |
41 | public static String getFileName(String fileName){ |
42 | String[] ss = fileName.split( "." ); |
43 | fileName = ss[ 0 ]; |
44 | String[] ss2 = fileName.split( "/" ); |
45 | fileName = ss[ss.length- 1 ]; |
46 | return fileName; |
47 | } |
48 | } |

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日