Android examples for Hardware:CPU Information
Read the first line of "/proc/cpuinfo" file, and check if it is 64 bit.
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Locale; public class Main { private static final String PROC_CPU_INFO_PATH = "/proc/cpuinfo"; private static boolean LOGENABLE = false; /**/*from w w w . j a va2 s .c o m*/ * Read the first line of "/proc/cpuinfo" file, and check if it is 64 bit. */ public static boolean isCPUInfo64() { File cpuInfo = new File(PROC_CPU_INFO_PATH); if (cpuInfo != null && cpuInfo.exists()) { InputStream inputStream = null; BufferedReader bufferedReader = null; try { inputStream = new FileInputStream(cpuInfo); bufferedReader = new BufferedReader(new InputStreamReader( inputStream), 512); String line = bufferedReader.readLine(); if (line != null && line.length() > 0 && line.toLowerCase(Locale.US).contains("arch64")) { return true; } } catch (Throwable t) { } finally { try { if (bufferedReader != null) { bufferedReader.close(); } } catch (Exception e) { e.printStackTrace(); } try { if (inputStream != null) { inputStream.close(); } } catch (Exception e) { e.printStackTrace(); } } } return false; } }