Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.BufferedReader;

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

public class Main {
    public static String getCPUMaxOneCore() {
        StringBuilder sb = new StringBuilder();
        String line = null;

        String txtInfo = "";
        try {
            Process proc = Runtime.getRuntime().exec("cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
            InputStream is = proc.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            try {
                while ((line = br.readLine()) != null) {
                    if (line.length() > 2) {
                        txtInfo = line;
                    }
                }
            } catch (IOException e) {
                // Log.v("getStringFromInputStream", "------ getStringFromInputStream " + e.getMessage());
            } finally {
                if (br != null) {
                    try {
                        br.close();
                    } catch (IOException e) {
                        //      Log.v("getStringFromInputStream", "------ getStringFromInputStream " + e.getMessage());
                    }
                }
            }

        } catch (IOException e) {

        }
        return txtInfo;
    }
}