📄 meminfo.java
字号:
package fr.umlv.projet.IG;import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class Meminfo{ private static String MemTotal; private static String MemFree; private static String Buffers; private static String Cached; private static String SwapCached; private static String Active; private static String Inactive; private static String HighTotal; private static String HighFree; private static String LowTotal; private static String LowFree; private static String SwapTotal; private static String SwapFree; private static String Dirty; private static String Writeback; private static String Mapped; private static String Slab; private static String CommitLimit; private static String Committed_AS; private static String PageTables; private static String VmallocTotal; private static String VmallocUsed; private static String VmallocChunk; private static String HugePages_Total; private static String HugePages_Free; private static String Hugepagesize; static{ try { Scanner sc = new Scanner(new File("/proc/meminfo")); while(sc.hasNext()){ String s = sc.next(); if(s.contains("MemTotal")) MemTotal = sc.next(); if(s.contains("SwapTotal")) SwapTotal = sc.next(); } } catch (FileNotFoundException e) { e.printStackTrace(); } } // KB private static void enregistreData(Scanner sc){ String s = sc.next(); if(s.contains("MemFree")) MemFree = sc.next(); if(s.contains("Buffers")) Buffers = sc.next(); if(s.contains("Cached")) Cached = sc.next(); if(s.contains("SwapCached")) SwapCached = sc.next(); if(s.contains("Active")) Active = sc.next(); if(s.contains("Inactive")) Inactive = sc.next(); if(s.contains("HighTotal")) HighTotal = sc.next(); if(s.contains("HighFree")) HighFree = sc.next(); if(s.contains("LowTotal")) LowTotal = sc.next(); if(s.contains("LowFree")) LowFree = sc.next();// if(s.contains("SwapTotal"))// SwapTotal = sc.next(); if(s.contains("SwapFree")) SwapFree = sc.next(); if(s.contains("Dirty")) Dirty = sc.next(); if(s.contains("Writeback")) Writeback = sc.next(); if(s.contains("Mapped")) Mapped = sc.next(); if(s.contains("Slab")) Slab = sc.next(); if(s.contains("CommitLimit")) CommitLimit = sc.next(); if(s.contains("Committed_AS")) Committed_AS = sc.next(); if(s.contains("PageTables")) PageTables = sc.next(); if(s.contains("VmallocTotal")) VmallocTotal = sc.next(); if(s.contains("VmallocUsed")) VmallocUsed = sc.next(); if(s.contains("VmallocChunk")) VmallocChunk = sc.next(); if(s.contains("HugePages_Total")) HugePages_Total = sc.next(); if(s.contains("HugePages_Free")) HugePages_Free = sc.next(); if(s.contains("Hugepagesize")) Hugepagesize = sc.next(); } public static void update(){ try { Scanner sc = new Scanner(new File("/proc/meminfo")); while(sc.hasNext()){ enregistreData(sc); } } catch (FileNotFoundException e) { e.printStackTrace(); } } public static String getActive() { return Active; } public static String getBuffers() { return Buffers; } public static String getCached() { return Cached; } public static String getCommitLimit() { return CommitLimit; } public static String getCommitted_AS() { return Committed_AS; } public static String getDirty() { return Dirty; } public static String getHighFree() { return HighFree; } public static String getHighTotal() { return HighTotal; } public static String getHugePages_Free() { return HugePages_Free; } public static String getHugePages_Total() { return HugePages_Total; } public static String getHugepagesize() { return Hugepagesize; } public static String getInactive() { return Inactive; } public static String getLowFree() { return LowFree; } public static String getLowTotal() { return LowTotal; } public static String getMapped() { return Mapped; } public static String getMemFree() { return MemFree; } public static String getMemTotal() { return MemTotal; } public static String getPageTables() { return PageTables; } public static String getSlab() { return Slab; } public static String getSwapCached() { return SwapCached; } public static String getSwapFree() { return SwapFree; } public static String getSwapTotal() { return SwapTotal; } public static String getVmallocChunk() { return VmallocChunk; } public static String getVmallocTotal() { return VmallocTotal; } public static String getVmallocUsed() { return VmallocUsed; } public static String getWriteback() { return Writeback; } public static void main(String[] args) { System.out.println(MemTotal); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -