List of usage examples for java.lang Runtime getRuntime
public static Runtime getRuntime()
From source file:Main.java
public static void exec(String cmd) { Process exec;//from w ww . java 2 s . com try { exec = Runtime.getRuntime().exec(cmd); InputStream in = exec.getInputStream(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static Process execRuntimeProcess(String cmd) { Runtime localRuntime = Runtime.getRuntime(); try {/*from www . j a v a 2s .co m*/ Process pro = localRuntime.exec("su"); DataOutputStream out = new DataOutputStream(pro.getOutputStream()); out.writeBytes(cmd + " \n"); return pro; } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static void test11() { try {/*from ww w.java2s .c o m*/ // xcopy c:\img d:\file /d/e String cmdStr = "cmd /c xcopy c:\\img d:\\file /d/e"; Runtime.getRuntime().exec(cmdStr); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void clearLog() { try {//from w ww . ja va 2 s . c om Runtime.getRuntime().exec(new String[] { "logcat", "-c" }); } catch (IOException e) { Log.e(TAG, e.toString()); } }
From source file:Main.java
/** * Find out how many cores are available to the JVM. * *///from w w w . j ava 2s .c o m public static int getCoreCount() { int retval = Runtime.getRuntime().availableProcessors(); return retval; }
From source file:Main.java
public static String getAdbPort() throws IOException { Process process = Runtime.getRuntime().exec("getprop service.adb.tcp.port"); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); return reader.readLine(); }
From source file:Main.java
private static void initProcess() { if (process == null) try {/*w w w. j a va 2 s . com*/ process = Runtime.getRuntime().exec("su"); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Find out how many cores are available to the JVM. * *///w w w . ja va2 s .c o m public static int getCoreCount() { int retval = Runtime.getRuntime().availableProcessors(); if (retval > 4) { retval = 4; } return retval; }
From source file:Main.java
public static String getDns() { try {//from ww w .java 2s . c o m Process p = Runtime.getRuntime().exec("getprop net.dns1"); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String dns = in.readLine(); return dns; } catch (IOException e1) { e1.printStackTrace(); } return null; }
From source file:Main.java
public static void RunAsRootNoOutput(String[] cmds) { try {//from www. j a va2 s. c o m Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd + "\n"); } os.writeBytes("exit\n"); os.flush(); } catch (Exception e) { e.printStackTrace(); } }