标签:style blog color os io ar for 文件 div
1 private String getTotalMemory() { 2 String str1 = "/proc/meminfo";// 系统内存信息文件 3 String str2; 4 String[] arrayOfString; 5 long initial_memory = 0; 6 try { 7 FileReader localFileReader = new FileReader(str1); 8 BufferedReader localBufferedReader = new BufferedReader( 9 localFileReader, 8192); 10 str2 = localBufferedReader.readLine();// 读取meminfo第一行,系统总内存大小 11 12 arrayOfString = str2.split("\\s+"); 13 for (String num : arrayOfString) { 14 Log.i(str2, num + "\t"); 15 } 16 17 initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024;// 获得系统总内存,单位是KB,乘以1024转换为Byte 18 localBufferedReader.close(); 19 20 } catch (IOException e) { 21 } 22 return Formatter.formatFileSize(getBaseContext(), initial_memory);// Byte转换为KB或者MB,内存大小规格化 23 }
标签:style blog color os io ar for 文件 div
原文地址:http://www.cnblogs.com/androidsj/p/3946798.html