configuration.java

来自「有关j2me的很好的例子可以研究一下」· Java 代码 · 共 65 行

JAVA
65
字号
/** * * @(#)Configuration.java	1.3 01/05/15 * * Copyright 2001 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. */package com.sun.midp;/** access the implementation configuration file parameters. */public class Configuration {    /** Don't let anyone instantiate this class */    private Configuration() {    }    /**     * Gets the implementation property indicated by the specified key.     *     * @param      key   the name of the implementation property.     * @return     the string value of the implementation property,     *             or <code>null</code> if there is no property with that key.     *     * @exception  NullPointerException if <code>key</code> is     *             <code>null</code>.     * @exception  IllegalArgumentException if <code>key</code> is empty.     */    public static String getProperty(String key) {	// If key is null, then a NullPointerException is thrown.	// If key is blank, then throw a specific IllegalArgumentException        if (key.length() ==  0) {            throw new IllegalArgumentException("key can't be empty");        }        return getProperty0(key);    }    /**     * Gets the implementation property indicated by the specified key or     * returns the specifid default value.     *     * @param      key   the name of the implementation property.     * @param      def   the default value for the property if not     *                  specified in the configuration files or command      *                  line over rides.     * @return     the string value of the implementation property,     *             or <code>null</code> if there is no property with that key.     *     * @exception  NullPointerException if <code>key</code> is     *             <code>null</code>.     * @exception  IllegalArgumentException if <code>key</code> is empty.     */    public static String getPropertyDefault(String key, String def) {	String result = getProperty(key);	return (result != null ? result : def);    }    /**     * native interface to the configuration parameter storage.     *     * @param      key   the name of the implementation property.     * @return     the string value of the implementation property,     *             or <code>null</code> if there is no property with that key.     */    private native static String getProperty0(String key);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?