Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Parses a String boolean to a Boolean Object
     * 
     * @param bool String boolean to parse
     * @param defaultValue Default Boolean if parsing fails
     * @return A parsed Boolean
     */
    public static boolean parseBool(String bool, boolean defaultValue) {
        if (bool == null)
            return defaultValue;
        if (bool.equalsIgnoreCase("on") || bool.equalsIgnoreCase("true") || bool.equalsIgnoreCase("yes"))
            return true;
        if (bool.equalsIgnoreCase("off") || bool.equalsIgnoreCase("false") || bool.equalsIgnoreCase("no"))
            return false;
        return defaultValue;
    }
}