List of usage examples for java.util Properties Properties
public Properties()
From source file:Main.java
/** * Gets ad hoc properties from a thread pool. * @return Ad hoc properties. //w ww.j a v a 2 s . co m */ public static Properties getProperties(ThreadPoolExecutor threadPoolExecutor) { Properties res = null; { if (threadPoolExecutor != null) { res = new Properties(); decorateProperties(threadPoolExecutor, res); } } return res; }
From source file:Main.java
public static Properties clone(Properties input) { Properties result = new Properties(); result.putAll(input); return result; }
From source file:Main.java
public static String findBuildPropValueOf(String prop) { String mBuildPath = "/system/build.prop"; String DISABLE = "disable"; String value = null;// ww w .jav a 2s . c om try { //create properties construct and load build.prop Properties mProps = new Properties(); mProps.load(new FileInputStream(mBuildPath)); //get the property value = mProps.getProperty(prop, DISABLE); Log.d("TAG", String.format("Helpers:findBuildPropValueOf found {%s} with the value (%s)", prop, value)); } catch (IOException ioe) { Log.d("TAG", "failed to load input stream"); } catch (NullPointerException npe) { //swallowed thrown by ill formatted requests } if (value != null) { return value; } else { return DISABLE; } }
From source file:Main.java
/** * Read file from SDCARD//from w ww.j a va 2 s .c o m * * @param filepath * @throws IOException */ public static void readfromsdcard(String filepath) throws IOException { // FileInputStream fis = new FileInputStream("sdcard/test.properties"); FileInputStream fis = new FileInputStream(filepath); Properties cfg = new Properties(); cfg.load(fis); }
From source file:Main.java
/** * (android) read from file//from w w w . j av a2 s . c om * * @param fileName * @return */ public static String androidFileload(Context con, String fileName) { Properties properties = new Properties(); try { FileInputStream stream = con.openFileInput(fileName); properties.load(stream); } catch (FileNotFoundException e) { return null; } catch (IOException e) { return null; } return properties.get(FILE_ENCODING).toString(); }
From source file:Main.java
static String getDataDir(final Context c) { final String defaultDataDir = String.format("%s/.bitcoin", getDir(c).getAbsolutePath()); try {/* ww w.ja va 2 s.com*/ final Properties p = new Properties(); p.load(new BufferedInputStream(new FileInputStream(getBitcoinConf(c)))); return p.getProperty("datadir", defaultDataDir); } catch (final IOException e) { return defaultDataDir; } }
From source file:com.sosee.util.PropertyUtil.java
public static String readValue(String key) { Properties props = new Properties(); try {/*from w w w .ja va 2s . c o m*/ InputStream in = new BufferedInputStream(new FileInputStream(getFilePath())); props.load(in); String value = props.getProperty(key); return value == null ? "" : value; } catch (Exception e) { return ""; } }
From source file:Main.java
/** * (android) write to file//from w w w .j av a 2 s . co m * * @param fileName * @param toSave * @return */ public static boolean androidFileSave(Context con, String fileName, String toSave) { Properties properties = new Properties(); properties.put(FILE_ENCODING, toSave); try { FileOutputStream stream = con.openFileOutput(fileName, Context.MODE_WORLD_WRITEABLE); properties.store(stream, ""); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } return true; }
From source file:PropertyLoader.java
public static Properties loadProperties(String name, ClassLoader loader) throws Exception { if (name.startsWith("/")) name = name.substring(1);// w ww . j a va 2 s . c o m if (name.endsWith(SUFFIX)) name = name.substring(0, name.length() - SUFFIX.length()); Properties result = new Properties(); InputStream in = null; if (loader == null) loader = ClassLoader.getSystemClassLoader(); if (LOAD_AS_RESOURCE_BUNDLE) { name = name.replace('/', '.'); ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault(), loader); for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) { result.put((String) keys.nextElement(), rb.getString((String) keys.nextElement())); } } else { name = name.replace('.', '/'); if (!name.endsWith(SUFFIX)) name = name.concat(SUFFIX); in = loader.getResourceAsStream(name); if (in != null) { result = new Properties(); result.load(in); // can throw IOException } } in.close(); return result; }
From source file:Main.java
public static String findBuildPropValueOf(String prop) { String mBuildPath = "/system/build.prop"; String DISABLE = "disable"; String value = null;/*from w w w. ja va 2 s . co m*/ try { //create properties construct and load build.prop Properties mProps = new Properties(); mProps.load(new FileInputStream(mBuildPath)); //get the property value = mProps.getProperty(prop, DISABLE); Log.d(TAG, String.format("Helpers:findBuildPropValueOf found {%s} with the value (%s)", prop, value)); } catch (IOException ioe) { Log.d(TAG, "failed to load input stream"); } catch (NullPointerException npe) { //swallowed thrown by ill formatted requests } if (value != null) { return value; } else { return DISABLE; } }