请问这个java.lang.RuntimeException异常原因是什么
执行以下代码时,提示Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: big.txt not found!!!
java菜鸟,请问谁能指点一下这个异常的原因呢,big.txt是存在的啊。
public static Map<String,Integer> train(){
[color=#FF0000]InputStream is = new SpellCorrect().getClass().getClassLoader().getResourceAsStream("big.txt");
if(is == null){
throw new RuntimeException("big.txt not found!!!");
}
Map<String,Integer> map = new HashMap<String,Integer>();[/color]
try {
//读取语料库big.txt
BufferedReader br = new BufferedReader(new InputStreamReader(is , "UTF-8"), 512);
String s="";
while ((s = br.readLine()) != null) {
// 去掉文档中除字母外的所有符号
s = s.replaceAll("\\pP|\\pS|\\pM|\\pN|\\pC", "");
// 将文档转成小写,然后切分成单词,存在list中
s = s.toLowerCase();
String[] splits = s.split(" ");
for (int j = 0; j < splits.length; j++) {
if (!" ".equals(splits[j]) && !"".equals(splits[j]) && !splits[j].equals(null)){
if(map.containsKey(splits[j])){
Integer count=map.get(splits[j]);
map.put(splits[j], count+1);
}else{
map.put(splits[j], 1);
}
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
finally{
try{
is.close();
}catch(Exception e){
e.printStackTrace();
}
}
return map;
}