方案1:
long result = 0L;
try {
String line;
BufferedReader br = new BufferedReader(new FileReader("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"));
if ((line = br.readLine()) != null) {
result = Long.parseLong(line);
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
方案2:
String result = "";
ProcessBuilder cmd;
try {
String[] args = {"/system/bin/cat", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"};
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[24];
while (in.read(re) != -1) {
result = result + new String(re);
}
in.close();
} catch (IOException ex) {
ex.printStackTrace();
result = "N/A";
}
return result.trim();