Created
November 11, 2011 06:44
-
-
Save shaobin0604/1357369 to your computer and use it in GitHub Desktop.
get cpu info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 获取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