Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.Log;
import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String getCPUMax() {
        String txtInfo = "";
        try {
            Process proc = Runtime.getRuntime().exec("cat /proc/cpuinfo");
            InputStream is = proc.getInputStream();
            StringBuilder sb = new StringBuilder();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String line = null;
            try {
                while ((line = br.readLine()) != null) {
                    Log.v("TestLog", line);
                    if (line.indexOf("BogoMIPS") >= 0) {
                        txtInfo = line.substring(8);
                    }
                }
            } catch (IOException e) {
                // Log.v("getStringFromInputStream", "------ getStringFromInputStream " + e.getMessage());
            } finally {
                if (br != null) {
                    try {
                        br.close();
                    } catch (IOException e) {
                    }
                }
            }
        } catch (IOException e) {
            Log.e("getCpuInfo", "------ getCpuInfo " + e.getMessage());
        }
        return txtInfo;
    }
}