get Boolean from Properties - Java java.util

Java examples for java.util:Properties File

Description

get Boolean from Properties

Demo Code


//package com.java2s;

import java.util.Properties;

public class Main {
    /**// w  ww . j a  va2  s. c o m
     * @param prop The Properties set
     * @param key the key used to store this property
     * @param def a default in case the property cannot be retrieved
     */
    public static boolean getBoolean(Properties prop, final String key,
            final boolean def) {
        final String value = prop.getProperty(key);
        return value == null ? def : value.equalsIgnoreCase("true");
    }
}

Related Tutorials