public static IConfig createFromResource(Class<?> owner, String fileName) throws MException { try { URL url = MSystem.locateResource(owner, fileName); if (fileName.endsWith(".xml")) return new XmlConfigFile(url.openStream()); if (fileName.endsWith(".properties")) return new PropertiesConfigFile(url.openStream()); if (fileName.endsWith(".json")) return new JsonConfigFile(url.openStream()); } catch (Throwable t) { throw new MException(fileName,t); } throw new NotFoundException(fileName); }
public static synchronized List<String> getPasswordList() { if (passwordList != null) return passwordList; try { // from https://github.com/danielmiessler/SecLists - Please respect MIT License, is compatible with this Apache 2.0 license URL res = MSystem.locateResource(MValidator.class, "10-million-password-list-top-100000.txt"); InputStream is = res.openStream(); final LinkedList<String> list = new LinkedList<>(); MFile.readLines(is, new Observer() { @Override public void update(Observable o, Object arg) { String v = (String)arg; // to lower case and trimm v = v.trim().toLowerCase(); if (v.length() > 0) list.add(v); } }); is.close(); passwordList = Collections.unmodifiableList(list); } catch (Throwable t) { MLogUtil.log().i(MValidator.class,t); } return passwordList; }
properties = new Properties(); try { URL m_url = locateResource(owner, propertyFile); if (m_url == null) { log.w("Properties file not found", propertyFile);
mhusConfigUrl = MSystem.locateResource(this, getApplicationConfigName()); } catch (IOException e) { log.i(getApplicationConfigName(),e);
public void init() { try { URL url = MSystem.locateResource(this, "SqlDbStorage.xml"); DbConnection con = pool.getConnection(); XmlConfigFile data = new XmlConfigFile(url.openStream()); data.setString("prefix", prefix); pool.getDialect().createStructure(data, con, null, false); con.close(); } catch (Exception e) { log().e(e); } }
mhusConfigUrl = MSystem.locateResource(this, getApplicationConfigName()); } catch (IOException e) { log.i(getApplicationConfigName(),e);