filedeal.java

来自「java编写的一个网络象棋,通过对方ip连接,开始游戏,同时可以进行聊天,聊天部」· Java 代码 · 共 41 行

JAVA
41
字号
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 + =
减小字号Ctrl + -
显示快捷键?