Java判断当前是win/linux...系统

    public static void main(String[] args) {
        String os = System.getProperty("os.name").toLowerCase();
        if (os.contains("win")) {
            System.out.println("win");
        } else if (os.contains("mac")) {
            System.out.println("mac");
        } else if (os.contains("linux")) {
            System.out.println("linux");
        } else {
            throw new UnsupportedOperationException("Unsupported operating system: " + os);
        }
    }
posted @ 2025-04-17 14:33  wds09  阅读(33)  评论(0)    收藏  举报