checker.java
来自「面向对象设计项目」· Java 代码 · 共 51 行
JAVA
51 行
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 + =
减小字号Ctrl + -
显示快捷键?