NO IMAGE
private Set<String> readSensitiveWordFile() throws Exception{
//存放檔案內容的set集合
Set<String> set = null;
//獲取檔案的路徑
String path = Thread.currentThread().getContextClassLoader().getResource("sensitive.txt").getPath();
//讀取檔案
File file = new File(path);   
//建立讀取流
InputStreamReader read = new InputStreamReader(new FileInputStream(path),ENCODING);
try {
//判斷檔案是否存在
if(file.isFile() && file.exists()){      
//初始化set集合
set = new HashSet<String>();
//緩衝區讀取流
BufferedReader bufferedReader = new BufferedReader(read);
//迴圈讀取檔案中內容,每次讀取一行內容
String txt = null;
while((txt = bufferedReader.readLine()) != null){    
//讀取檔案,將檔案內容放入到set中
set.add(txt);
}
}
else{         //不存在丟擲異常資訊
throw new Exception("敏感詞庫檔案不存在");
}
} catch (Exception e) {
throw e;
}finally{
read.close();     //關閉檔案流
}
return set;
}