首页>代码>spring boot集成sigar极简入门实例>/springboot-sigar/src/main/java/com/simon/springbootsigar/sigar/SigarUtil.java
package com.simon.springbootsigar.sigar;

import com.google.common.io.Resources;
import org.hyperic.sigar.Sigar;

import java.io.File;

/**
 * @author Simon
 */
public class SigarUtil {

    public final static Sigar sigar = initSigar();

    public static Sigar initSigar() {
        try {
            String file = Resources.getResource("sigar/.sigar_shellrc").getFile();
            File classPath = new File(file).getParentFile();
            String path = System.getProperty("java.library.path");
            if (OsCheck.getOperatingSystemType() == OsCheck.OSType.Windows) {
                path += ";" + classPath.getCanonicalPath();
            } else {
                path += ":" + classPath.getCanonicalPath();
            }
            System.setProperty("java.library.path", path);
            return new Sigar();
        } catch (Exception e) {
            return null;
        }
    }
}
最近下载更多
Seaskye  LV14 2023年11月4日
crosa_Don  LV18 2023年5月22日
最代码官方  LV167 2023年3月18日
最近浏览更多
47795851  LV1 3月14日
chenhuahao  LV18 2023年11月6日
Seaskye  LV14 2023年11月4日
漫步的海星  LV4 2023年9月26日
444105047  LV6 2023年7月28日
lipanlong  LV10 2023年7月6日
best2018  LV46 2023年5月23日
crosa_Don  LV18 2023年5月22日
matintalorr  LV10 2023年5月9日
fewfsdaf  LV4 2023年4月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友