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, String def) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:Main.java

/**
 * Run a command with the given data as input.
 *//*from www  . java 2 s  .  co  m*/
public static void systemIn(String command, String data) throws Exception {
    String cmd[] = new String[3];
    cmd[0] = System.getProperty("SHELL", "/bin/sh");
    cmd[1] = "-c";
    cmd[2] = command;
    Process p = Runtime.getRuntime().exec(cmd);
    PrintWriter w = new PrintWriter(p.getOutputStream());
    w.print(data);
    w.flush();
    w.close();
    p.waitFor();
}

From source file:Main.java

/**
 * Run a command and return its output./*from   ww  w  .j  a  v a  2 s .  c o m*/
 */
public static String systemOut(String command) throws Exception {
    int c;
    String cmd[] = new String[3];
    cmd[0] = System.getProperty("SHELL", "/bin/sh");
    cmd[1] = "-c";
    cmd[2] = command;
    Process p = Runtime.getRuntime().exec(cmd);

    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
    StringBuilder s = new StringBuilder();
    while ((c = r.read()) != -1)
        s.append((char) c);
    p.waitFor();

    return s.toString();
}

From source file:Main.java

/**
 * Run a command with the given data as input.
 *///from   w w w  . j ava2 s  .c o m
public static void systemIn(String command, String data) throws Exception {
    String[] cmd = new String[3];
    cmd[0] = System.getProperty("SHELL", "/bin/sh");
    cmd[1] = "-c";
    cmd[2] = command;
    Process p = Runtime.getRuntime().exec(cmd);
    PrintWriter w = new PrintWriter(p.getOutputStream());
    w.print(data);
    w.flush();
    w.close();
    p.waitFor();
}

From source file:Main.java

/**
 * Run a command and return its output./* ww w.ja v a 2s  . c  om*/
 */
public static String systemOut(String command) throws Exception {
    int c;
    String[] cmd = new String[3];
    cmd[0] = System.getProperty("SHELL", "/bin/sh");
    cmd[1] = "-c";
    cmd[2] = command;
    Process p = Runtime.getRuntime().exec(cmd);

    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
    StringBuilder s = new StringBuilder();
    while ((c = r.read()) != -1) {
        s.append((char) c);
    }
    p.waitFor();

    return s.toString();
}

From source file:Main.java

private static String i(Context context) {
    if (h == null) {
        String s = (new WebView(context)).getSettings().getUserAgentString();
        if (s == null || s.length() == 0 || s.equals("Java0")) {
            String s1 = System.getProperty("os.name", "Linux");
            String s2 = (new StringBuilder()).append("Android ").append(android.os.Build.VERSION.RELEASE)
                    .toString();// ww w  . j a va 2  s  .  com
            Locale locale = Locale.getDefault();
            String s3 = locale.getLanguage().toLowerCase();
            if (s3.length() == 0)
                s3 = "en";
            String s4 = locale.getCountry().toLowerCase();
            String s5;
            String s6;
            if (s4.length() > 0)
                s5 = (new StringBuilder()).append(s3).append("-").append(s4).toString();
            else
                s5 = s3;
            s6 = (new StringBuilder()).append(Build.MODEL).append(" Build/").append(Build.ID).toString();
            s = (new StringBuilder()).append("Mozilla/5.0 (").append(s1).append("; U; ").append(s2).append("; ")
                    .append(s5).append("; ").append(s6).append(") AppleWebKit/0.0 (KHTML, like ")
                    .append("Gecko) Version/0.0 Mobile Safari/0.0").toString();
        }
        h = (new StringBuilder()).append(s).append(" (Mobile; ").append("afma-sdk-a-v").append("4.1.0")
                .append(")").toString();
    }
    return h;
}