Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

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

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:Main.java

/**
 * checks if a condition is true/*from w ww. j ava 2 s.  c o m*/
 *
 * @param condition value of the condition attribute
 * @return result of the evaluation of the condition
 */
public static boolean checkCondition(String condition) {
    if ((condition == null) || condition.trim().equals("")) {
        return true;
    }

    String value = condition.trim();
    if (value.charAt(0) == '!') {
        return System.getProperty(value.substring(1)) == null;
    }

    return System.getProperty(value) != null;
}

From source file:Main.java

public static void saveAllScripts(String projectName, String fileName, String content)
        throws FileNotFoundException {
    fileName = fileName.substring(1, fileName.length());
    String path = System.getProperty("user.dir") + "/workspace/"
            + projectName.substring(0, projectName.indexOf(System.getProperty("file.separator"))) + "/Scripts/"
            + fileName;// w  ww  . j  av a 2s .  c  o m
    writeFile(path, content, false);
}

From source file:Main.java

public static URL createURL(String fileName) throws MalformedURLException {
    URL url = null;/*from  w  w w .jav  a 2  s . c  om*/
    try {
        url = new URL(fileName);
    } catch (MalformedURLException ex) {
        File f = new File(fileName);
        try {
            String path = f.getAbsolutePath();

            String fs = System.getProperty("file.separator");
            if (fs.length() == 1) {
                char sep = fs.charAt(0);
                if (sep != '/') {
                    path = path.replace(sep, '/');
                }
                if (path.charAt(0) != '/') {
                    path = '/' + path;
                }
            }
            path = "file://" + path;
            url = new URL(path);
        } catch (MalformedURLException e) {
            throw e;
        }
    }
    return url;
}

From source file:FileUtils.java

public static URL getRelativePathToURL(String name) {
    String dir = System.getProperty("user.dir");
    return getRelativePathToURL(dir, name);
}