public static void loadProps(Properties props, InputStream inStr) throws IOException { loadProps(props, inStr, false); }
/** * A more efficient Properties.load * * Some of the other differences: * - UTF-8 encoding, not ISO-8859-1 * - No escaping! This does not process or drop backslashes * - '#' or ';' starts a comment line, but '!' does not * - Leading whitespace is not trimmed * - '=' is the only key-termination character (not ':' or whitespace) * * As of 0.9.10, an empty value is allowed. * * As in Java Properties, duplicate keys are allowed, last one wins. * */ public static void loadProps(Properties props, File file) throws IOException { loadProps(props, file, false); }
/** * @param forceLowerCase if true forces the keys to lower case (not the values) */ public static void loadProps(Properties props, File file, boolean forceLowerCase) throws IOException { loadProps(props, new FileInputStream(file), forceLowerCase); }
public static List<ClientAppConfig> getClientApps(File cfgFile) { Properties clientApps = new Properties(); try { DataHelper.loadProps(clientApps, cfgFile); } catch (IOException ioe) { return Collections.emptyList(); } return getClientApps(clientApps); }
private static Properties getClientAppProps(RouterContext ctx) { Properties rv = new Properties(); File cfgFile = configFile(ctx); // fall back to use router.config's clientApp.* lines if (!cfgFile.exists()) { System.out.println("Warning - No client config file " + cfgFile.getAbsolutePath()); rv.putAll(ctx.router().getConfigMap()); return rv; } try { DataHelper.loadProps(rv, cfgFile); } catch (IOException ioe) { System.out.println("Error loading the client app properties from " + cfgFile.getAbsolutePath() + ' ' + ioe); } return rv; }
private void loadProps(Properties props, File file) throws IOException { InputStream fin = null; try { fin = new BufferedInputStream(new FileInputStream(file), 1); fin.mark(1); int c = fin.read(); fin.reset(); if (c == '#') { // uncompressed if (_log.shouldLog(Log.INFO)) _log.info("Loading uncompressed profile data from " + file.getName()); DataHelper.loadProps(props, fin); } else { // compressed (or corrupt...) if (_log.shouldLog(Log.INFO)) _log.info("Loading compressed profile data from " + file.getName()); DataHelper.loadProps(props, new GZIPInputStream(fin)); } } finally { try { if (fin != null) fin.close(); } catch (IOException e) {} } }
private RunStandalone(String args[]) throws Exception { Properties p = new Properties(); if (APP_CONFIG_FILE.exists()) { try { DataHelper.loadProps(p, APP_CONFIG_FILE); } catch (IOException ioe) {} } _context = new I2PAppContext(p); File base = _context.getBaseDir(); File xml = new File(base, "jetty-i2psnark.xml"); _jettyStart = new JettyStart(_context, null, new String[] { xml.getAbsolutePath() } ); if (args.length > 1) { _port = Integer.parseInt(args[1]); } if (args.length > 0) { _host = args[0]; } }
/** * The config for a torrent * @param ih 20-byte infohash * @return non-null, possibly empty * @since 0.9.15 */ private Properties getConfig(byte[] ih) { Properties rv = new OrderedProperties(); File conf = configFile(_configDir, ih); synchronized(_configLock) { // one lock for all try { DataHelper.loadProps(rv, conf); } catch (IOException ioe) {} } return rv; }
/** * Load up the config data from the file * * @return properties loaded * @throws IllegalArgumentException if unable to load from file */ private synchronized Properties loadConfig(String configFile) { File cfgFile = new File(configFile); if (!cfgFile.isAbsolute()) cfgFile = new File(I2PAppContext.getGlobalContext().getConfigDir(), configFile); if (!cfgFile.exists()) { if (_log.shouldLog(Log.ERROR)) _log.error("Unable to load the controllers from " + cfgFile.getAbsolutePath()); throw new IllegalArgumentException("Unable to load the controllers from " + cfgFile.getAbsolutePath()); } Properties props = new Properties(); try { DataHelper.loadProps(props, cfgFile); return props; } catch (IOException ioe) { if (_log.shouldLog(Log.ERROR)) _log.error("Error reading the controllers from " + cfgFile.getAbsolutePath(), ioe); throw new IllegalArgumentException("Error reading the controllers from " + cfgFile.getAbsolutePath(), ioe); } }
if (_configFile.exists()) { try { DataHelper.loadProps(_config, _configFile); } catch (IOException ioe) { _log.error("Error loading I2PSnark config " + _configFile, ioe);
/** * Load up the keys from the persistFilename. */ @SuppressWarnings("unchecked") private void loadKeys() { synchronized (nameToPrivKeys) { nameToPrivKeys.clear(); File file = new File(persistFilename); // now in config dir but check base dir too... if (!file.exists()) { if (file.isAbsolute()) return; file = new File(I2PAppContext.getGlobalContext().getConfigDir(), persistFilename); if (!file.exists()) return; } try { Properties props = new Properties(); DataHelper.loadProps(props, file); // unchecked Map foo = props; nameToPrivKeys.putAll(foo); if (_log.shouldInfo()) _log.info("Loaded " + nameToPrivKeys.size() + " private keys from " + file); } catch (IOException ioe) { _log.error("Unable to read the keys from " + file, ioe); } } }
File f = new File(filename); if (f.canRead()) { DataHelper.loadProps(props, f); props.remove(PROP_SHUTDOWN_IN_PROGRESS); } else {
DataHelper.loadProps(p, cfgFile); _configLastRead = _context.clock().now(); } catch (IOException ioe) {
Properties oldProps = new Properties(); try { DataHelper.loadProps(oldProps, oldFile);
/** * Sets up the test fixture. * * Called before every test case method. */ protected void setUp() throws IOException { _context = I2PAppContext.getGlobalContext(); log = _context.logManager().getLog(LogSettingsTest.class); p = new Properties(); f = new File("logger.config"); if(!f.exists()){ FileWriter temp = new FileWriter(f); temp.close(); } DataHelper.loadProps(p, f); origMinimumOnScreenLevel = p.getProperty("logger.record.net.i2p.util.LogSettingsTest", Log.STR_ERROR); origLogSettings = p.getProperty("logger.minimumOnScreenLevel", Log.STR_CRIT); }
File f = new File(filenames[i]); if ( (f.exists()) && (f.canRead()) ) { DataHelper.loadProps(hosts, f, true); int sz = hosts.size(); if (sz > 0) {
if (keys.exists()) { Properties opts = new Properties(); DataHelper.loadProps(opts, keys); String s = opts.getProperty(_destFile); if (s != null) {
DataHelper.loadProps(opts, file); } else if (cfile != null) {
Properties opts = new Properties(); if (file.exists()) DataHelper.loadProps(opts, file); boolean shouldSave = SSLUtil.verifyKeyStore(opts); if (shouldSave)
DataHelper.loadProps(properties, configFile); configurationLoaded = true; } catch (IOException e) {