Java tutorial
//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 getKernelVersion() { Process process = null; try { process = Runtime.getRuntime().exec("cat /proc/version"); } catch (IOException e) { e.printStackTrace(); } InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr, 8 * 1024); String result = ""; String line; try { while ((line = br.readLine()) != null) { result += line; } } catch (IOException e) { e.printStackTrace(); } if (result != "") { String keyword = "version "; int index = result.indexOf(keyword); line = result.substring(index + keyword.length()); index = line.indexOf(" "); return line.substring(0, index); } return "Unknown"; } }