Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.security.AccessController;
import java.security.PrivilegedAction;

public class Main {
    /**
     * Gets an integer property as a privileged action.
     *
     * @param property_name the integer property name
     *
     * @return the property value
     */
    public static Integer getPrivilegedInteger(final String property_name) {
        return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
            public Integer run() {
                return Integer.getInteger(property_name);
            }
        });
    }

    /**
     * Gets an integer property as a privileged action.
     *
     * @param property_name the integer property name
     * @param default_val   the default value to use if the property is not defined
     *
     * @return the property value
     */
    public static Integer getPrivilegedInteger(final String property_name, final int default_val) {
        return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
            public Integer run() {
                return Integer.getInteger(property_name, default_val);
            }
        });
    }
}