获得jar中数据,获得jar数据,// example c
分享于 点击 47793 次 点评:275
获得jar中数据,获得jar数据,// example c
// example code of access data using getResource() public static File getDefalutPath() { if(defalutPath == null) { String defPath = System.getProperty("mmseg.dic.path"); log.info("look up in mmseg.dic.path="+defPath); if(defPath == null) { URL url = Dictionary.class.getClassLoader().getResource("data"); if(url != null) { defPath = url.getFile(); log.info("look up in classpath="+defPath); } else { defPath = System.getProperty("user.dir")+"/data"; log.info("look up in user.dir="+defPath); } } defalutPath = new File(defPath); if(!defalutPath.exists()) { log.warning("defalut dic path="+defalutPath+" not exist"); } } return defalutPath; }
用户点评