Java determines whether the operating system is Windows or Linux

public class Test {
  public static void main(String[] args) throws Exception {
    Boolean flag = isLinux();
    System.out.println("flag: " + flag);
  }
  /**
   * Determine whether it is Linux or Windows, if Linux returns true, if Windows returns false
   */
  private static Boolean isLinux() {
    String os = System.getProperty("os.name");
    System.out.println("os.name: " + os);
    if (os.toLowerCase().startsWith("win")) {
      return false;
    }
    return true;
    }	
}

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325262028&siteId=291194637