本文整理汇总了Java中org.hyperic.sigar.FileSystemUsage.getAvail方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUsage.getAvail方法的具体用法?Java FileSystemUsage.getAvail怎么用?Java FileSystemUsage.getAvail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hyperic.sigar.FileSystemUsage
的用法示例。
在下文中一共展示了FileSystemUsage.getAvail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: output
import org.hyperic.sigar.FileSystemUsage; //导入方法依赖的package包/类
public void output(FileSystem fs) throws SigarException {
long used, avail, total, pct;
try {
FileSystemUsage usage;
if (fs instanceof NfsFileSystem) {
NfsFileSystem nfs = (NfsFileSystem)fs;
if (!nfs.ping()) {
println(nfs.getUnreachableMessage());
return;
}
}
usage = this.sigar.getFileSystemUsage(fs.getDirName());
if (this.opt_i) {
used = usage.getFiles() - usage.getFreeFiles();
avail = usage.getFreeFiles();
total = usage.getFiles();
if (total == 0) {
pct = 0;
}
else {
long u100 = used * 100;
pct = u100 / total +
((u100 % total != 0) ? 1 : 0);
}
}
else {
used = usage.getTotal() - usage.getFree();
avail = usage.getAvail();
total = usage.getTotal();
pct = (long)(usage.getUsePercent() * 100);
}
} catch (SigarException e) {
//e.g. on win32 D:\ fails with "Device not ready"
//if there is no cd in the drive.
used = avail = total = pct = 0;
}
String usePct;
if (pct == 0) {
usePct = "-";
}
else {
usePct = pct + "%";
}
ArrayList items = new ArrayList();
items.add(fs.getDevName());
items.add(formatSize(total));
items.add(formatSize(used));
items.add(formatSize(avail));
items.add(usePct);
items.add(fs.getDirName());
items.add(fs.getSysTypeName() + "/" + fs.getTypeName());
printf(items);
}