Sets the value of the system property named in key to the given value,
returning the previous value or null if the property was not previously set.
public static StringclearProperty(String key)
Removes the system property named in key, returning the previous value, or
null if the property was not previously set.
public static voidsetProperties(Properties props)
Sets the Properties object that defines all system properties to be
props.
All these methods are security checked and may throw SecurityException. However, being denied
access to the entire set of properties does not necessarily mean you will be denied access to individual
properties.
Property values are stored as strings, but the strings can represent other types, such as integers or booleans.
Methods are available to read properties and decode them into some of the primitive types. These decoding
methods are static methods of the primitive type's class. Each method has a String parameter that names the
property to retrieve. Some forms have a second parameter (shown as def later) that is the default value to
return if no property is found with that name. Methods that lack a default value parameter return an object that
contains the default value for the type. All these methods decode values in the standard formats for constants
of the primitive type:
public static boolean Boolean.getBoolean(String name)
public static Integer Integer.getInteger(String name)
public static Integer
Integer.getInteger(String name, Integer def)
public static Integer Integer.getInteger(String name, int def)
public static Long Long.getLong(String name)
public static Long Long.getLong(String name, Long def)
public static Long Long.getLong(String name, long def)
The getBoolean method is different from the othersit returns a boolean value instead of an object of
class Boolean. If the property isn't present, getBoolean returns false; the other methods return null.
The classes Character, Byte, Short, Float, and Double do not have property fetching methods. You
can get the value as a string and use the mechanisms described in "String Conversions" on page 316 to
convert to the appropriate primitive type.
23.1.3. Utility Methods
The System class also contains a number of utility methods:
public static longcurrentTimeMillis()
Returns the current time in milliseconds since the epoch (00:00:00 GMT,
January 1, 1970). The time is returned in a long. Sophisticated applications
may require more functionality (see "Time, Dates, and Calendars" on page
695).
public static longnanoTime()