📄 filedeal.java
字号:
package myfile;
import javax.swing.JFileChooser;
import java.io.*;
public class FileDeal {
private JFileChooser chooser;
private String filename;
RandomAccessFile file;
public FileDeal(){
chooser = new JFileChooser();
filename = "chess.txt";
}
public void save(String str){
chooser.setDialogTitle("保存");
chooser.showSaveDialog(null);
File f = this.chooser.getSelectedFile();
try{
file = new RandomAccessFile(f,"rw");
file.writeChars("test");
}catch(FileNotFoundException e){
System.out.println("FileNotFoundException");
}catch(IOException e){
System.out.println("IOException");
}
}
public void load(){
chooser.showOpenDialog(null);
File f = this.chooser.getSelectedFile();
try{
file = new RandomAccessFile(f,"rw");
file.read();
}catch(Exception e){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -