加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090218034303/http://developer.android.com:80/reference/java/util/Properties.html
public class

Properties

extends Hashtable<K, V>
java.lang.Object
   ↳ java.util.Dictionary<K, V>
     ↳ java.util.Hashtable<K, V>
       ↳ java.util.Properties
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Properties is a Hashtable where the keys and values must be Strings. Each Properties can have a default Properties which specifies the default values which are used if the key is not in this Properties.

Summary

Fields
protected Properties defaults The default values for this Properties.
Public Constructors
Properties()
Constructs a new Properties object.
Properties(Properties properties)
Constructs a new Properties object using the specified default properties.
Public Methods
String getProperty(String name, String defaultValue)
Searches for the property with the specified name.
String getProperty(String name)
Searches for the property with the specified name.
void list(PrintStream out)
Lists the mappings in this Properties to the specified PrintStream in a human readable form.
void list(PrintWriter writer)
Lists the mappings in this Properties to the specified PrintWriter in a human readable form.
synchronized void load(InputStream in)
Loads properties from the specified InputStream.
synchronized void loadFromXML(InputStream in)
Enumeration<?> propertyNames()
Returns all of the property names that this Properties contains.
void save(OutputStream out, String comment)
This method is deprecated. Does not throw an IOException, use store(OutputStream, String)
Object setProperty(String name, String value)
Maps the specified key to the specified value.
synchronized void store(OutputStream out, String comment)
Stores the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning.
void storeToXML(OutputStream os, String comment)
synchronized void storeToXML(OutputStream os, String comment, String encoding)
[Expand]
Inherited Methods
From class java.util.Hashtable
From class java.util.Dictionary
From class java.lang.Object
From interface java.util.Map

Fields

protected Properties defaults

The default values for this Properties.

Public Constructors

public Properties ()

Constructs a new Properties object.

public Properties (Properties properties)

Constructs a new Properties object using the specified default properties.

Parameters
properties the default properties

Public Methods

public String getProperty (String name, String defaultValue)

Searches for the property with the specified name. If the property is not found, look in the default properties. If the property is not found in the default properties, answer the specified default.

Parameters
name the name of the property to find
defaultValue the default value
Returns
  • the named property value

public String getProperty (String name)

Searches for the property with the specified name. If the property is not found, look in the default properties. If the property is not found in the default properties, answer null.

Parameters
name the name of the property to find
Returns
  • the named property value

public void list (PrintStream out)

Lists the mappings in this Properties to the specified PrintStream in a human readable form.

Parameters
out the PrintStream

public void list (PrintWriter writer)

Lists the mappings in this Properties to the specified PrintWriter in a human readable form.

Parameters
writer the PrintWriter

public synchronized void load (InputStream in)

Loads properties from the specified InputStream. The properties are of the form key=value, one property per line.

Parameters
in the input stream
Throws
IOException

public synchronized void loadFromXML (InputStream in)

public Enumeration<?> propertyNames ()

Returns all of the property names that this Properties contains.

Returns
  • an Enumeration containing the names of all properties

public void save (OutputStream out, String comment)

This method is deprecated.Does not throw an IOException, use store(OutputStream, String)

Saves the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning. The output from this method is suitable for being read by the load() method.

Parameters
out the OutputStream
comment the comment
Throws
ClassCastException when the key or value of a mapping is not a String

public Object setProperty (String name, String value)

Maps the specified key to the specified value. If the key already exists, the old value is replaced. The key and value cannot be null.

Parameters
name the key
value the value
Returns
  • the old value mapped to the key, or null

public synchronized void store (OutputStream out, String comment)

Stores the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning. The output from this method is suitable for being read by the load() method.

Parameters
out the OutputStream
comment the comment
Throws
IOException
ClassCastException when the key or value of a mapping is not a String

public void storeToXML (OutputStream os, String comment)

Throws
IOException

public synchronized void storeToXML (OutputStream os, String comment, String encoding)

Throws
IOException