Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static String[] getUvValues() { ArrayList<String> value = new ArrayList<String>(); try { // Open the file that is the first // command line parameter FileInputStream fstream = null; File f = new File("/sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels"); if (f.exists()) { fstream = new FileInputStream("/sys/devices/system/cpu/cpufreq/vdd_table/vdd_levels"); } else { File ff = new File("/sys/devices/system/cpu/cpu0/cpufreq/UV_mV_table"); if (ff.exists()) { fstream = new FileInputStream("/sys/devices/system/cpu/cpu0/cpufreq/UV_mV_table"); } } // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; // Read File Line By Line while ((strLine = br.readLine()) != null) { strLine = strLine.trim(); if ((strLine.length() != 0)) { String[] val = strLine.split("\\s+"); value.add(val[1]); } } // Close the input stream in.close(); } catch (Exception e) {// Catch exception if any System.err.println("Error: " + e.getMessage()); } String[] values = new String[value.size() - 1]; values = value.toArray(values); return values; } }