📄 fileutil.java
字号:
package t26lab3_2.GUI;
import java.io.*;
public class FileUtil {
public static BufferedReader bufread;
public static BufferedWriter bufwriter;
static File writefile;
static String filepath;
static String filecontent;
static String read;
static String readStr = "";
public static String readfile(String path)
{
try {
readStr = "";
filepath = path;
File file = new File(filepath);
FileReader fileread = new FileReader(file);
bufread = new BufferedReader(fileread);
while ((read = bufread.readLine()) != null) {
readStr = readStr + read;
}
} catch (Exception d) {
System.out.println(d.getMessage());
}
return readStr;
}
public static void writefile(String path, String content, boolean append) {
try {
boolean addStr = append;
filepath = path;
filecontent = content;
writefile = new File(filepath);
if (writefile.exists() == false)
{
writefile.createNewFile();
writefile = new File(filepath);
}
FileWriter filewriter = new FileWriter(writefile, addStr);
bufwriter = new BufferedWriter(filewriter);
filewriter.write(filecontent);
filewriter.flush();
} catch (Exception d) {
System.out.println(d.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -