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/折磨了两天了 终于解决了 请问一个缩小并保存image对象的问题 怎么加入一个判定条件,根据当前线程的的名字,来做出动作。 学了java学什么数据库比较好? java 坦克大战问题 table不显示 卸载jdk 怎样用字符串表示当前目录下的所有子目录? 一个有关jxl的使用问题 请问大家:jbuilder6同一工程下怎么在另外一个包调用这个方法? 如何判断输入的一个数是不是整型?? 关于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/
折磨了两天了 终于解决了