use of oshi.software.os.OSFileStore in project yyl_example by Relucent.
the class OshiExample method infoFileSystem.
private static void infoFileSystem(FileSystem fs) {
println("FileStore");
for (OSFileStore store : fs.getFileStores()) {
String name = store.getName();
String mount = store.getMount();
String type = store.getType();
long total = store.getTotalSpace();
long free = store.getUsableSpace();
long used = total - free;
double usage = ((double) used * 100) / total;
// 文件系统名
println(" name: " + name);
// 挂载路径
println(" mount: " + mount);
// 盘符类型
println(" type: " + type);
// 总大小
println(" total: " + total);
// 剩余大小
println(" free: " + free);
// 已经使用量
println(" used: " + used);
// 资源的使用率
println(" usage: " + usage);
}
}
use of oshi.software.os.OSFileStore in project ats-framework by Axway.
the class OshiSystemInformation method listFileSystems.
@Override
public IFileSystem[] listFileSystems() {
FileSystem fs = this.systemInfo.getOperatingSystem().getFileSystem();
// enumerate only local drives. (Network ones are excluded)
List<OSFileStore> fileStores = fs.getFileStores(true);
List<IFileSystem> fileSystems = new ArrayList<IFileSystem>();
for (OSFileStore fileStore : fileStores) {
fileSystems.add(new OshiFileSystem(fileStore, fileStore.getMount()));
}
return fileSystems.toArray(new IFileSystem[fileSystems.size()]);
}
use of oshi.software.os.OSFileStore in project ats-framework by Axway.
the class OshiSystemInformation method getFileSystem.
@Override
public IFileSystem getFileSystem(String devName) {
try {
FileSystem fs = this.os.getFileSystem();
List<OSFileStore> fileStores = fs.getFileStores();
for (OSFileStore fileStore : fileStores) {
if (fileStore.getName().equals(devName)) {
return new OshiFileSystem(fileStore, fileStore.getName());
}
}
throw new SystemInformationException("No such file system drive device '" + devName + "'");
} catch (Exception e) {
throw new SystemInformationException("Could not obtain file system for/from device '" + devName + "'", e);
}
}
Aggregations