【发布时间】:2012-02-27 09:48:55
【问题描述】:
public void tokenize(){
// attempt creating a reader for the input
reader = this.newReader();
while((line = reader.readLine())!=null){
tokenizer = new StringTokenizer(line);
while(tokenizer.hasMoreTokens()){
toke = (tokenizer.nextToken().trim());
this.tokenType(toke);
//System.out.println(this.tokenType(toke));
}
}
}
private BufferedReader newReader(){
try {//attempt to read the file
reader = new BufferedReader(new FileReader("Input.txt"));
}
catch(FileNotFoundException e){
System.out.println("File not found");
}
catch(IOException e){
System.out.println("I/O Exception");
}
return reader;
}
我以为我已经在 newReader() 中处理了它,但它似乎无法访问。 Eclipse 建议使用 throws,但我不明白它在做什么,或者它是否解决了问题?
感谢您的帮助!
【问题讨论】:
-
你说的是哪个 IOException,
reader.readLine()?
标签: java exception-handling io try-catch