/** * 得到汉字字库的集合 * @return */ public static Map getChinaWordStorage() { BufferedReader bu=null; try { Map map=new TreeMap(); bu=new BufferedReader(new InputStreamReader(new FileInputStream(getPropertiesByKey("chinaWord")),"UTF-8"));//文件放在tomcat/bin下 String line= bu.readLine(); // System.out.println(line); while(line!=null&&!line.equals("")) { map.put(line.trim(), line.trim().substring(0,1)); line= bu.readLine(); } //bu.close(); return map; } catch (Exception e) { e.printStackTrace(); return null; } finally{ if(bu!=null){ try { bu.close(); } catch (IOException e) { e.printStackTrace(); } } } }
原文:http://www.cnblogs.com/W203654/p/3772738.html