700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android查看内核版本号 Android获取系统内核版本的方法

android查看内核版本号 Android获取系统内核版本的方法

时间:2023-01-23 00:09:50

相关推荐

android查看内核版本号 Android获取系统内核版本的方法

看网上关于这个问题的帖子挺少的,和大家分享一下。

public static String getKernelVersion() {

String kernelVersion = "";

InputStream inputStream = null;

try {

inputStream = new FileInputStream("/proc/version");

} catch (FileNotFoundException e) {

e.printStackTrace();

return kernelVersion;

}

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 8 * 1024);

String info = "";

String line = "";

try {

while ((line = bufferedReader.readLine()) != null) {

info += line;

}

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

bufferedReader.close();

inputStream.close();

} catch (IOException e) {

e.printStackTrace();

}

}

try {

if (info != "") {

final String keyword = "version ";

int index = info.indexOf(keyword);

line = info.substring(index + keyword.length());

index = line.indexOf(" ");

kernelVersion = line.substring(0, index);

}

} catch (IndexOutOfBoundsException e) {

e.printStackTrace();

}

return kernelVersion;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。