⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 finderror.java

📁 一个快速检测拼写程序
💻 JAVA
字号:
import java.io.*;
import java.util.Hashtable;

public class FindError{		
	public FindError(File F1,File F2,File file){
		ReadDictionary dictionary=new ReadDictionary(F1);
		try{
			if(!file.exists())throw new FileExistError();
			if(!file.isFile())throw new IsNotFile();
			if(!file.canRead())throw new CanNotRead();
			FileInputStream in=null;
			InputStreamReader read=null;
			OutputStream out=null;
			String s=new String("");
			String last=new String("");
			try {
				 in=new FileInputStream(file);
				 read=new InputStreamReader(in);
				 out=new FileOutputStream(F2);
				 OutputStreamWriter write=new OutputStreamWriter(out);
				 BufferedReader br=new BufferedReader(read);
				 FileInputStream in1=new FileInputStream(F1);
				 InputStreamReader read1=new InputStreamReader(in1);
				 BufferedReader br1=new BufferedReader(read1);
				 int i=1,j;
				 write.write("被检查文件名:"+file.getAbsolutePath()+" 字典名:"+br1.readLine()+"\r\n");
				 write.write("错误为:\r\n");
				 write.flush();
				 while((s=br.readLine())!=null){
				         Word w=new Word(s);
				         for(j=0;j<w.length();j++){
				     	    if(((Integer)dictionary.dictionary.get(w.split[j]))==null){
				     	    	 write.write(w.split[j]+":位于第"+i+"行\r\n");
				     	    	 write.flush();
				     	    	}    	
				     	    else last+=" "+w.split[j];	
				           }
				         i++;
				         last+="\r\n";
				       } 
				 write.write("----------------------------------------------------------------------------------------------------\r\n");
				 write.write("最后正确的结果:\r\n");
				 write.write(last);
				 write.flush();      
			   }
			catch(IOException e){;}
			finally{
				 if(read!=null)try{read.close();}catch(IOException e){;}
				}	
		   }	 	
		  catch(FileExistError e1){
			 System.out.println(e1.toString());
			}
		  catch(IsNotFile e2){
		  	 System.out.println(e2.toString());
		  	}
		  catch(CanNotRead e3){
		  	 System.out.println(e3.toString());
		  	}
		}
	}
/*	
class FileExistError extends Exception{
	public FileExistError(){
	     super();
		}
	public String toString(){
		return "源文件不存在";
		}	
	}
	
class IsNotFile	extends Exception{
	public IsNotFile(){
		super();
		}
	public String toString(){
		return "源不是文件名";
		}			
	}
	
class CanNotRead extends Exception{
	public CanNotRead(){
		super();
		}
	public String toString(){
		return "源文件不能读";
		}	
	}	*/

⌨️ 快捷键说明

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