Java Code Examples for oshi.software.os.FileSystem

The following examples show how to use oshi.software.os.FileSystem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: supplierShop   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 2
Source Project: mogu_blog_v2   Source File: ServerInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 3
Source Project: RuoYi-Vue   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 4
Source Project: ruoyiplus   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 5
Source Project: NutzSite   Source File: Server.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 6
Source Project: spring-boot-demo   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 7
/**
 * ���ô�����Ϣ
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 8
Source Project: Shiro-Action   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 9
Source Project: spring-boot-demo   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 10
Source Project: RuoYi   Source File: Server.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 11
Source Project: LuckyFrameWeb   Source File: Server.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 12
Source Project: boot-actuator   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os)
{
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray)
    {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 13
/**
 * 获取磁盘信息
 *
 * @return /
 */
private Map<String, Object> getDiskInfo(OperatingSystem os) {
	Map<String, Object> diskInfo = new LinkedHashMap<>();
	try {
		FileSystem fileSystem = os.getFileSystem();
		List<OSFileStore> fsArray = fileSystem.getFileStores();
		for (OSFileStore fs : fsArray) {
			diskInfo.put("total", fs.getTotalSpace() > 0 ? FileUtil.getSize(fs.getTotalSpace()) : "?");
			long used = fs.getTotalSpace() - fs.getUsableSpace();
			diskInfo.put("available", FileUtil.getSize(fs.getUsableSpace()));
			diskInfo.put("used", FileUtil.getSize(used));
			diskInfo.put("usageRate", df.format(used / (double) fs.getTotalSpace() * 100));
		}
	} catch (Exception e) {
		log.error("{}", e);
	}
	return diskInfo;
}
 
Example 14
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFileInfo sysFile = new SysFileInfo();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));

        if (total == 0) {
            sysFile.setUsage(0);
        } else {
            sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
        }

        sysFiles.add(sysFile);
    }
}
 
Example 15
Source Project: spring-boot-demo   Source File: Server.java    License: MIT License 6 votes vote down vote up
/**
 * 设置磁盘信息
 */
private void setSysFiles(OperatingSystem os) {
    FileSystem fileSystem = os.getFileSystem();
    OSFileStore[] fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray) {
        long free = fs.getUsableSpace();
        long total = fs.getTotalSpace();
        long used = total - free;
        SysFile sysFile = new SysFile();
        sysFile.setDirName(fs.getMount());
        sysFile.setSysTypeName(fs.getType());
        sysFile.setTypeName(fs.getName());
        sysFile.setTotal(convertFileSize(total));
        sysFile.setFree(convertFileSize(free));
        sysFile.setUsed(convertFileSize(used));
        sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
        sysFiles.add(sysFile);
    }
}
 
Example 16
Source Project: eladmin   Source File: MonitorServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取磁盘信息
 * @return /
 */
private Map<String,Object> getDiskInfo(OperatingSystem os) {
    Map<String,Object> diskInfo = new LinkedHashMap<>();
    FileSystem fileSystem = os.getFileSystem();
    List<OSFileStore> fsArray = fileSystem.getFileStores();
    for (OSFileStore fs : fsArray){
        diskInfo.put("total", fs.getTotalSpace() > 0 ? FileUtil.getSize(fs.getTotalSpace()) : "?");
        long used = fs.getTotalSpace() - fs.getUsableSpace();
        diskInfo.put("available", FileUtil.getSize(fs.getUsableSpace()));
        diskInfo.put("used", FileUtil.getSize(used));
        diskInfo.put("usageRate", df.format(used/(double)fs.getTotalSpace() * 100));
    }
    return diskInfo;
}
 
Example 17
Source Project: DimpleBlog   Source File: ServerServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取磁盘信息
 *
 * @return /
 */
private Map<String, Object> getDiskInfo(OperatingSystem os) {
    Map<String, Object> diskInfo = new LinkedHashMap<>();
    FileSystem fileSystem = os.getFileSystem();
    List<OSFileStore> fsArray = Arrays.asList(fileSystem.getFileStores());
    for (OSFileStore fs : fsArray) {
        diskInfo.put("total", fs.getTotalSpace() > 0 ? FileUtils.getSizeString(fs.getTotalSpace()) : "?");
        long used = fs.getTotalSpace() - fs.getUsableSpace();
        diskInfo.put("available", FileUtils.getSizeString(fs.getUsableSpace()));
        diskInfo.put("used", FileUtils.getSizeString(used));
        diskInfo.put("usageRate", df.format(used / (double) fs.getTotalSpace() * 100));
    }
    return diskInfo;
}