Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

In this page you can find the example usage for java.lang System getProperties.

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:Main.java

/**
 * Get a subset of the system properties for names that match at least one of the given prefixes.
 * @throws SecurityException  As in {@link System#getProperties}.
 */// ww  w .  j a v  a2  s .  c  om
public static Properties getProperties(String... prefixes) {
    Properties result = new Properties();
    // Properties should be a Map<String, String>, but it's not defined that way.  Depending on the
    // implementation, it may even allow clients to put non-string entries.
    for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
        for (String prefix : prefixes) {
            if (entry.getKey() instanceof String && ((String) entry.getKey()).startsWith(prefix)) {
                result.put(entry.getKey(), entry.getValue());
                break;
            }
        }
    }
    return result;
}

From source file:hu.bme.mit.trainbenchmark.benchmark.blazegraph.driver.BlazegraphDriver.java

public BlazegraphDriver(final boolean inferencing) throws IOException, RepositoryException {
    super(inferencing);

    // remove Blazegraph banner text
    System.getProperties().setProperty("com.bigdata.Banner.quiet", "true");
    System.getProperties().setProperty("com.bigdata.util.config.LogUtil.quiet", "true");

    // load journal properties from resources
    final Properties props = loadProperties("/blazegraph.properties");
    // instantiate a sail
    final String journalFile = (String) props.get("com.bigdata.journal.AbstractJournal.file");
    FileUtils.deleteQuietly(new File(journalFile));

    sail = new BigdataSail(props);
    repository = new BigdataSailRepository(sail);
    repository.initialize();// w w  w .  j a  v a  2 s. c om
}

From source file:net.officefloor.tutorial.dynamichttpserver.DynamicHttpServerTest.java

public void testTemplateLogic() {

    TemplateLogic logic = new TemplateLogic();

    assertEquals("Number of properties", System.getProperties().size(),
            logic.getTemplateData().getProperties().length);

}

From source file:Main.java

/**
 * Get a subset of the system properties for names that match at least one of the given prefixes.
 * Returns a String map; in the unusual case that a value is not a String, it is converted 
 * via {@code toString()}./*w w w . j av  a 2 s.  c om*/
 * @throws SecurityException  As in {@link System#getProperties}.
 */
public static Map<String, String> getPropertiesAsMap(String... prefixes) {
    Map<String, String> result = new HashMap<String, String>();
    for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
        for (String prefix : prefixes) {
            if (entry.getKey() instanceof String && ((String) entry.getKey()).startsWith(prefix)) {
                result.put((String) entry.getKey(), entry.getValue().toString());
                break;
            }
        }
    }
    return result;
}

From source file:org.jamwiki.utils.WikiLogger.java

/**
 *
 *//*from  ww w  .j a v a2 s  .c o  m*/
public static String getDefaultLogFile() {
    System.out.println(System.getProperties());
    String logFile = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator")
            + DEFAULT_LOG_FILENAME;
    return logFile;
}

From source file:com.gopivotal.cloudfoundry.test.core.RuntimeUtils.java

public RuntimeUtils() {
    this(System.getenv(), ManagementFactory.getRuntimeMXBean(), System.getProperties());
}

From source file:com.github.born2snipe.maven.log.LogFilterApplier.java

public String apply(String text, String logLevel) {
    if (System.getProperties().containsKey(OFF_SWITCH)) {
        return text;
    }/*from ww w  .  ja v  a2 s  .c  o  m*/

    boolean displayDebugInfo = showDebugInfo();

    if (config == null)
        config = configLoader.loadConfiguration(displayDebugInfo);

    String result = text;
    if (displayDebugInfo)
        System.out.println("Original log Text: [" + text + "]");

    for (LogEntryFilter filter : filters) {
        LogEntryFilter.Context context = new LogEntryFilter.Context(result, config, displayDebugInfo, logLevel);
        result = filter.filter(context);

        if (displayDebugInfo)
            System.out.println("Log text filtered by " + filter + ": [" + result + "]");

        if (StringUtils.isBlank(result)) {
            return result;
        }
    }

    return result;
}

From source file:com.hp.test.framework.runner.Runallthetests.java

@BeforeTest
public void pres(ITestContext ctx) throws JellyException, FileNotFoundException {
    context = new JellyContext();
    context.setVariable("xpath", new XpathSupport());
    context.setVariable("env", System.getProperties());
    context.setVariable("outcome", Boolean.TRUE);
    //         Map<String,String> suiteName_list = ctx.getCurrentXmlTest().getTestParameters();
    //             for(String a:suiteName_list.keySet())
    //             System.out.println("key"+a+"value"+suiteName_list.get(a));

}

From source file:com.kamike.misc.FsUtils.java

public static void createDir(String dstPath) {
    Properties props = System.getProperties(); //    
    String osName = props.getProperty("os.name"); //???   
    Path newdir = FileSystems.getDefault().getPath(dstPath);

    boolean pathExists = Files.exists(newdir, new LinkOption[] { LinkOption.NOFOLLOW_LINKS });
    if (!pathExists) {
        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx");
        FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
        try {//from   w  w w . ja  va2  s.  c o  m
            if (!osName.contains("Windows")) {
                Files.createDirectories(newdir, attr);
            } else {
                Files.createDirectories(newdir);
            }
        } catch (Exception e) {
            System.err.println(e);

        }
    }
}

From source file:com.netflix.ndbench.core.config.SystemPropertiesConfigSource.java

@Override
public void initialize() {
    super.initialize();

    Properties systemProps = System.getProperties();

    for (final String key : systemProps.stringPropertyNames()) {
        if (!key.startsWith(NdBenchConstants.WEBAPP_NAME)) {
            continue;
        }/*from  ww  w .j  a v  a 2  s  . c om*/
        final String value = systemProps.getProperty(key);
        if (!StringUtils.isEmpty(value)) {
            data.put(key, value);
        }
    }
}