private void loadPrepDict() { _PrepDict = new DictSegment((char) 0); File file = new File(environment.configFile(), Dictionary.PATH_DIC_PREP); InputStream is = null; try { is = new FileInputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } if (is == null) { throw new RuntimeException("Preposition Dictionary not found!!!"); } try { BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512); String theWord; do { theWord = br.readLine(); if (theWord != null && !"".equals(theWord.trim())) { _PrepDict.fillSegment(theWord.trim().toCharArray()); } } while (theWord != null); logger.info("[Dict Loading] {},PrepDict Size:{}", file.toString(), _PrepDict.getDicNum()); } catch (IOException ioe) { System.err.println("Preposition Dictionary loading exception."); ioe.printStackTrace(); } finally { try { if (is != null) { is.close(); is = null; } } catch (IOException e) { e.printStackTrace(); } } }
private void loadMainDict() { _MainDict = new DictSegment((char) 0); File file = new File(environment.configFile(), Dictionary.PATH_DIC_MAIN); InputStream is = null; try { is = new FileInputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } if (is == null) { throw new RuntimeException("Main Dictionary not found!!!"); } try { BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512); String theWord; do { theWord = br.readLine(); if (theWord != null && !"".equals(theWord.trim())) { _MainDict.fillSegment(theWord.trim().toCharArray()); } } while (theWord != null); logger.info("[Dict Loading] {},MainDict Size:{}", file.toString(), _MainDict.getDicNum()); } catch (IOException ioe) { System.err.println("Main Dictionary loading exception."); ioe.printStackTrace(); } finally { try { if (is != null) { is.close(); is = null; } } catch (IOException e) { e.printStackTrace(); } } List<String> extDictFiles = configuration.getExtDictionarys(); if (extDictFiles != null) { for (String extDictName : extDictFiles) { File tempFile = new File(environment.configFile(), extDictName); try { is = new FileInputStream(tempFile); } catch (FileNotFoundException e) { e.printStackTrace(); } if (is == null) { continue; } try { BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512); String theWord; do { theWord = br.readLine(); if (theWord != null && !"".equals(theWord.trim())) { _MainDict.fillSegment(theWord.trim().toCharArray()); } } while (theWord != null); logger.info("[Dict Loading] {},MainDict Size:{}", file.toString(), _MainDict.getDicNum()); } catch (IOException ioe) { System.err.println("Extension Dictionary loading exception."); ioe.printStackTrace(); } finally { try { if (is != null) { is.close(); is = null; } } catch (IOException e) { e.printStackTrace(); } } } } }