Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Properties;

public class Main {
    /**
     * Gets the boolean property from the properties object.
     * @param key the key of the boolean property
     * @param properties the properties object to get the property from
     * @return the property value, false if the property does not exist
     */
    public static boolean getBoolean(String key, Properties properties) {
        return getBoolean(key, false, properties);
    }

    /**
     * Gets the boolean property from the properties object.
     * @param key the key of the boolean property
     * @param defaultValue the default value if the property doesn't exist
     * @param properties the properties object to get the property from
     * @return the property value, defaultValue if the property doesn't exist
     */
    public static boolean getBoolean(String key, boolean defaultValue, Properties properties) {
        if (properties.containsKey(key)) {
            return Boolean.valueOf(properties.getProperty(key, "false"));
        } else {
            return defaultValue;
        }
    }
}