Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
Created November 11, 2011 06:44
Show Gist options
  • Select an option

  • Save shaobin0604/1357369 to your computer and use it in GitHub Desktop.

Select an option

Save shaobin0604/1357369 to your computer and use it in GitHub Desktop.
get cpu info
/**
* 获取Cpu
*
*/
private String getCpu() {
ProcessBuilder cmd;
String result = "";
try {
String[] args = { "/system/bin/cat", "/proc/cpuinfo" };
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while (in.read(re) != -1) {
System.out.println(new String(re));
result = result + new String(re);
return result.toString();
}
in.close();
} catch (IOException ex) {
ex.printStackTrace();
}
return result.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment