java如何监控磁盘IO性能 java磁盘i/o 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public long getTotalByte(){ Sigar sigar = new Sigar(); long totalByte = 0; try { FileSystem[] fslist = sigar.getFileSystemList(); for (int i = 0; i < fslist.length; i++){ if (fslist[i].getType() == 2){ FileSystemUsage usage = sigar.getFileSystemUsage(fslist[i].getDirName()); totalByte += usage.getDiskReadBytes(); totalByte += usage.getDiskWriteBytes(); } } } catch (SigarException e) { // TODO Auto-generated catch block e.printStackTrace(); } return totalByte; }public static void main(String[] args) { TestIO io = new TestIO(); long tempTotal = io.getTotalByte(); for (int i = 0; i < 200; i++) { try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } long total = io.getTotalByte(); System.out.println( Integer.valueOf((int) ((total - tempTotal) / 1000)) + "kb"); tempTotal = total; } }引用jar包:http://sourceforge.net/projects/sigar/折磨了两天了 终于解决了 有人用sublime编辑器的吗?怎样设置默认保存字符编码为GBK? 毛一样的java…… 汉语句子的正则表达式? JButton 中文乱码 继续昨天关于ResultSet的问题,大家帮忙看看 高手救命啊 关于JAVA IO输入、输出这部分 焦点问题 怎样将下列的字符串变成数组啊 中国软件向印度学什么 (zt)-----唉!不服人家不行! 关于java数组并发与缓存行的一些疑惑,求解惑 一个简单的播放音频文件
public long getTotalByte(){
Sigar sigar = new Sigar();
long totalByte = 0;
try {
FileSystem[] fslist = sigar.getFileSystemList();
for (int i = 0; i < fslist.length; i++){
if (fslist[i].getType() == 2){
FileSystemUsage usage = sigar.getFileSystemUsage(fslist[i].getDirName());
totalByte += usage.getDiskReadBytes();
totalByte += usage.getDiskWriteBytes();
}
}
} catch (SigarException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return totalByte;
}public static void main(String[] args) {
TestIO io = new TestIO();
long tempTotal = io.getTotalByte();
for (int i = 0; i < 200; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long total = io.getTotalByte();
System.out.println( Integer.valueOf((int) ((total - tempTotal) / 1000)) + "kb");
tempTotal = total;
}
}引用jar包:http://sourceforge.net/projects/sigar/
折磨了两天了 终于解决了