get CPU Info - Android android.os

Android examples for android.os:CPU

Description

get CPU Info

Demo Code

import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {

  public static String getCPUInfo() {
    try {/* w w w .  j  a  va 2s . co m*/
      byte[] bs = new byte[1024];
      RandomAccessFile reader = new RandomAccessFile("/proc/cpuinfo", "r");
      reader.read(bs);
      String ret = new String(bs);
      int index = ret.indexOf(0);
      if (index != -1) {
        return ret.substring(0, index);
      } else {
        return ret;
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }
    return "";
  }

}

Related Tutorials