📄 sigarmeminfo.java
字号:
/* * SigarMemInfo.java * * Created on March 14, 2005, 12:30 PM */package net.hyperic.sigar.cmd;import net.hyperic.sigar.Mem;import net.hyperic.sigar.Swap;import net.hyperic.sigar.SigarException;/** * * @author Sean */public class SigarMemInfo extends SigarCommandBase { /** Creates a new instance of SigarMemInfo */ public SigarMemInfo() { super(); } /** * */ public Swap getSwap() throws SigarException { try { return this.sigar.getSwap(); } catch (SigarException e) { throw e; } } /** * */ public Mem getMem() throws SigarException { try { return this.sigar.getMem(); } catch (SigarException e) { throw e; } } /** * */ public void output() throws SigarException { try { output(null); } catch (SigarException e) { throw e; } } /** * */ public void output(String[] args) throws SigarException { Mem memInfo; Swap swapInfo; try { memInfo = getMem(); swapInfo = getSwap(); } catch( SigarException e) { throw e; } this.out.println("\tTotal\tUsed\tFree"); this.out.println("Mem: " + memInfo.getTotal() / 1024 + "\t" + memInfo.getUsed() / 1024 + "\t" + memInfo.getFree() / 1024); this.out.println("Swap: " + swapInfo.getTotal() / 1024 + "\t" + swapInfo.getUsed() / 1024 + "\t" + swapInfo.getFree() / 1024); this.out.println("RAM: " + memInfo.getRam() + "MB"); } public static void main( String[] args ) { try { SigarMemInfo info = new SigarMemInfo(); info.output(); } catch ( Exception ex ) { System.out.println( ex.getMessage() ); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -