All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.shoothzj.javatool.util.OSUtil Maven / Gradle / Ivy

There is a newer version: 3.1.15
Show newest version
package com.github.shoothzj.javatool.util;

import com.github.shoothzj.javatool.module.OperationSystem;
import lombok.extern.slf4j.Slf4j;

/**
 * @author hezhangjian
 */
@Slf4j
public class OSUtil {

    public static OperationSystem getOS() {
        String osName = EnvUtil.getOsName();
        if (osName.startsWith("Mac")) {
            return OperationSystem.MAC;
        } else if (osName.startsWith("Windows")) {
            return OperationSystem.WINDOWS;
        } else if (osName.startsWith("Linux")) {
            return OperationSystem.LINUX;
        }

        return OperationSystem.UNKNOWN;
    }

    public static String getDocumentPath() {
        OperationSystem operationSystem = getOS();
        if (operationSystem.equals(OperationSystem.MAC) || operationSystem.equals(OperationSystem.WINDOWS)) {
            return EnvUtil.getUserHome() + "/Documents";
        } else {
            return EnvUtil.getUserHome() + "/Documents";
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy