List of usage examples for java.util Properties getProperty
public String getProperty(String key, String defaultValue)
From source file:org.xinta.eazycode.common.test.selenium.SeleniumTestCase.java
/** * ?selenium client.//from w w w . j av a2s. co m * application.test.properties?selenium?,??. */ @BeforeClass public static void setUp() throws Exception { Properties p = PropertiesLoaderUtils.loadAllProperties(PROPERTY_FILE); String browser = p.getProperty(PROPERTY_BROWSER_NAME, DEFAULT_BROWSER); String url = p.getProperty(PROPERTY_URL_NAME, DEFAULT_URL); String host = p.getProperty(PROPERTY_SELENIUM_HOST_NAME, DEFAULT_SELENIUM_HOST); int port = Integer.valueOf(p.getProperty(PROPERTY_SELENIUM_PORT_NAME, DEFAULT_SELENIUM_PORT)); selenium = new DefaultSelenium(host, port, browser, url); selenium.start(); selenium.windowFocus(); selenium.windowMaximize(); }
From source file:cpcc.core.utils.VersionUtils.java
/** * @param resourceName the name of the resource to load for the version property. * @return the estimated version./*from w w w . j a v a 2 s . c o m*/ */ public static String getVersion(String resourceName) { InputStream propStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName); if (propStream == null) { return UNKNOWN_VERSION; } try { Properties props = new Properties(); props.load(propStream); return props.getProperty(PROP_APPLICATION_VERSION, UNKNOWN_VERSION); } catch (IOException e) { return UNKNOWN_VERSION; } }
From source file:Main.java
public static String findBuildPropValueOf(String prop) { String mBuildPath = "/system/build.prop"; String DISABLE = "disable"; String value = null;//from w ww . j a va 2 s . com 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
public static String findBuildPropValueOf(String prop) { String mBuildPath = "/system/build.prop"; String DISABLE = "disable"; String value = null;/*from w w w. j a va 2s .c o 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; } }
From source file:com.jdom.util.properties.PropertiesUtil.java
public static boolean getBoolean(Properties properties, String key, boolean defaultValue) { String stringValue = properties.getProperty(key, "" + defaultValue); return Boolean.parseBoolean(stringValue); }
From source file:com.ms.commons.utilities.StaticContentDeploy.java
private static String getPropertyFromFile(File propertyFile, String property) { FileInputStream inputStream = null; InputStreamReader reader = null; try {/*from ww w .j a v a 2 s . com*/ inputStream = new FileInputStream(propertyFile); reader = new InputStreamReader(inputStream, "utf-8"); Properties properties = new Properties(); properties.load(reader); return properties.getProperty(property, StringUtils.EMPTY); } catch (Exception e) { logger.error("StaticContentDeploy init failed", e); } finally { closeQuietly(inputStream, reader); } return StringUtils.EMPTY; }
From source file:io.fabric8.vertx.maven.plugin.components.impl.GroovyExtensionCombiner.java
public static List<String> merge(String projectName, String projectVersion, List<String> local, List<List<String>> deps) { List<String> extensionClassesList = new ArrayList<>(); List<String> staticExtensionClassesList = new ArrayList<>(); List<Properties> all = new ArrayList<>(); all.add(asProperties(local));/*from www .ja va 2 s . c o m*/ if (deps != null) { deps.forEach(s -> all.add(asProperties(s))); } for (Properties properties : all) { String staticExtensionClasses = properties.getProperty("staticExtensionClasses", "").trim(); String extensionClasses = properties.getProperty("extensionClasses", "").trim(); if (extensionClasses.length() > 0) { append(extensionClasses, extensionClassesList); } if (staticExtensionClasses.length() > 0) { append(staticExtensionClasses, staticExtensionClassesList); } } List<String> desc = new ArrayList<>(); desc.add("moduleName=" + projectName); desc.add("moduleVersion=" + projectVersion); if (extensionClassesList.size() > 0) { desc.add("extensionClasses=" + join(extensionClassesList)); } if (staticExtensionClassesList.size() > 0) { desc.add("staticExtensionClasses=" + join(staticExtensionClassesList)); } return desc; }
From source file:io.fabric8.vertx.maven.plugin.utils.GroovyExtensionCombiner.java
public static List<String> merge(String projectName, String projectVersion, Set<String> local, List<Set<String>> deps) { List<String> extensionClassesList = new ArrayList<>(); List<String> staticExtensionClassesList = new ArrayList<>(); List<Properties> all = new ArrayList<>(); all.add(asProperties(local));//w w w . j ava 2s .c o m if (deps != null) { deps.forEach(s -> all.add(asProperties(s))); } for (Properties properties : all) { String staticExtensionClasses = properties.getProperty("staticExtensionClasses", "").trim(); String extensionClasses = properties.getProperty("extensionClasses", "").trim(); if (extensionClasses.length() > 0) { append(extensionClasses, extensionClassesList); } if (staticExtensionClasses.length() > 0) { append(staticExtensionClasses, staticExtensionClassesList); } } List<String> desc = new ArrayList<>(); desc.add("moduleName=" + projectName); desc.add("moduleVersion=" + projectVersion); if (extensionClassesList.size() > 0) { desc.add("extensionClasses=" + join(extensionClassesList)); } if (staticExtensionClassesList.size() > 0) { desc.add("staticExtensionClasses=" + join(staticExtensionClassesList)); } return desc; }
From source file:actors.ConfigUtil.java
static ProcessBuilder buildProcess(String javaCmd, String etlJobName, long whEtlExecId, String cmdParam, Properties etlJobProperties) { String classPath = System.getProperty("java.class.path"); String outDir = etlJobProperties.getProperty(Constant.WH_APP_FOLDER_KEY, WH_APPLICATION_DEFAULT_DIRECTORY); String configFile = outDir + "/" + whEtlExecId + ".properties"; String[] cmdParams = isNotBlank(cmdParam) ? cmdParam.trim().split(" ") : new String[0]; ProcessBuilder pb = new ProcessBuilder(new ImmutableList.Builder<String>().add(javaCmd) .addAll(Arrays.asList(cmdParams)).add("-cp").add(classPath).add("-Dconfig=" + configFile) .add("-DCONTEXT=" + etlJobName).add("-Dlogback.configurationFile=etl_logback.xml") .add("-DLOG_DIR=" + outDir).add(Launcher.class.getCanonicalName()).build()); pb.redirectOutput(ProcessBuilder.Redirect.to(new File(outDir + "/stdout"))); pb.redirectError(ProcessBuilder.Redirect.to(new File(outDir + "/stderr"))); return pb;//from ww w.j a v a 2 s. com }
From source file:com.metamx.emitter.core.Emitters.java
static Map<String, Object> makeLoggingMap(Properties props) { Map<String, Object> loggingMap = Maps.newHashMap(); loggingMap.put("loggerClass", props.getProperty("com.metamx.emitter.logging.class", LoggingEmitter.class.getName())); loggingMap.put("logLevel", props.getProperty("com.metamx.emitter.logging.level", "debug")); return loggingMap; }