List of usage examples for java.lang Runtime getRuntime
public static Runtime getRuntime()
From source file:Main.java
private static void changeInnerFilePermission() { try {/*from w ww. ja va 2 s . c om*/ Runtime.getRuntime().exec("chmod 777 " + INNER_UDID_DIR_PATH); Runtime.getRuntime().exec("chmod 666 " + INNER_UDID_FILE_PATH); } catch (Exception e) { } }
From source file:Main.java
public static String getMac() { String macAdress = null;/*w w w . j a v a 2 s. c o m*/ String str = ""; try { Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address "); InputStreamReader ir = new InputStreamReader(pp.getInputStream()); LineNumberReader input = new LineNumberReader(ir); for (; null != str;) { str = input.readLine(); if (str != null) { macAdress = str.trim(); break; } } ir.close(); input.close(); } catch (IOException ex) { ex.printStackTrace(); } return macAdress; }
From source file:Main.java
public static int execRootCmdSilent(String cmd) { int result = -1; DataOutputStream dos = null;//from w ww . j a va 2s . c o m try { Process p = Runtime.getRuntime().exec("su"); dos = new DataOutputStream(p.getOutputStream()); dos.writeBytes(cmd + "\n"); dos.flush(); dos.writeBytes("exit\n"); dos.flush(); p.waitFor(); result = p.exitValue(); } catch (Exception e) { e.printStackTrace(); } finally { if (dos != null) { try { dos.close(); } catch (IOException e) { e.printStackTrace(); } } } return result; }
From source file:Main.java
public static String do_exec(String cmd) { String s = "/n"; try {/* w ww . j a va2 s . c o m*/ Process p = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; while ((line = in.readLine()) != null) { s += line + "/n"; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return s; }
From source file:Main.java
public static void setFileOrDirRW(String permission, String path) { try {//from w ww. j av a2s . co m String command = "chmod" + " " + permission + " " + path; Runtime runtime = Runtime.getRuntime(); runtime.exec(command); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static String getMac() { String result = ""; try {/*from w w w . jav a 2 s . c om*/ Process process = Runtime.getRuntime().exec("ipconfig /all"); InputStreamReader ir = new InputStreamReader(process.getInputStream()); LineNumberReader input = new LineNumberReader(ir); String line; while ((line = input.readLine()) != null) if (line.indexOf("Physical Address") > 0) { String MACAddr = line.substring(line.indexOf("-") - 2); result = MACAddr; } } catch (java.io.IOException e) { System.err.println("IOException " + e.getMessage()); } return result; }
From source file:Main.java
/**Returns max memory for app * @return current max memory size for app *//* w w w .j a v a2 s. com*/ private static long calcAvailableMemory() { long value = Runtime.getRuntime().maxMemory(); //String type = ""; if (Build.VERSION.SDK_INT >= 11) { value = (value / 1024) - (Runtime.getRuntime().totalMemory() / 1024); //type = "JAVA"; } else { value = (value / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024); //type = "NATIVE"; } return value; }
From source file:Main.java
public static void RunRootCmd(String cmd) { try {/*from w w w. ja v a2 s. c o m*/ // // run our command using 'su' to gain root // Process process = Runtime.getRuntime().exec("su"); DataOutputStream outputStream = new DataOutputStream(process.getOutputStream()); outputStream.writeBytes(cmd + "\n"); outputStream.flush(); outputStream.writeBytes("exit\n"); outputStream.flush(); process.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
public static String getSDRoot() { String pre = null;/*from w ww. java 2 s. c o m*/ String root = null; try { Runtime r = Runtime.getRuntime(); Process p = r.exec("ls mnt"); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String inline; while ((inline = br.readLine()) != null) { if (inline.contains("mmcblk")) { pre = inline; break; } } br.close(); root = "/mnt/" + pre + "/" + pre + "p1"; } catch (Exception e) { } return root; }
From source file:Main.java
public static void openLrucache() { lruCache = new LruCache<String, Bitmap>((int) Runtime.getRuntime().maxMemory() / 8) { @Override// ww w .j a va2 s.c o m protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); } }; }