📄 checker.java
字号:
package SpellCheck;
import java.io.*;
import java.util.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Checker extends JFrame{
public String errInfo =new String();
private boolean allRight;
public void check(MyDictionary aDic,String textLine) throws IOException{
String str=new String();
String s1=new String();
String s2=new String();
String err=new String();
int i=1;
int j=0;
allRight=true;
errInfo="字典名:"+aDic.getName()+"\n";
StringReader aReader =new StringReader(textLine);
BufferedReader input =new BufferedReader(aReader);
while((str=input.readLine())!=null){
if(str==null) str="end";
StringTokenizer st =new StringTokenizer(str," ~!@#$%^&*()_+|:;',.?{}<>-=`\"\\|[]/!#¥……()——【】;‘、,。、:“”·?《》1234567890");
while (st.hasMoreTokens()){
s1=st.nextToken();
s2=s1.toLowerCase();
j++;
if(!(aDic.contain(s2))){
err="出错单词“"+s1+"”位于第 "+i+" 行第 "+j+" 个";
errInfo=errInfo+err+"\n";
allRight=false;
}
}
i++;
j=0;
} //System.out.print(checkLine);
if(allRight)
errInfo=errInfo+"文本无错误";
}
public String checkInfo(){
return errInfo;
}
public void checkResult(){
JOptionPane.showMessageDialog(this,"检查完成!","成功",1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -