open.java

来自「模拟实现对windows的记事本多线程查找」· Java 代码 · 共 28 行

JAVA
28
字号
import java.io.*;
import javax.swing.*;

public class Open extends Thread{
	public void run(){
		if(FileDialogDemo.jfc.showOpenDialog(new JFileChooser())
				== FileDialogDemo.jfc.APPROVE_OPTION)
		{
			open(FileDialogDemo.jfc.getSelectedFile());		
		}
			
	}
	public static void open(File file){
		try{
			BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
			byte[] b = new byte[in.available()];
			in.read(b,0,b.length);
			FileDialogDemo.jta.append(new String(b,0,b.length));
			in.close();
			FileDialogDemo.lab.setText(file.getName() + "Opened");
		}
		catch(IOException ex){
			FileDialogDemo.lab.setText("Error opening" + file.getName());
		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?