|
Android 2.3 Gingerbread | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
public class Properties
A Properties object is a Hashtable where the keys and values
must be Strings. Each property can have a default
Properties list which specifies the default
values to be used when a given key is not found in this Properties
instance.
Hashtable,
System.getProperties(),
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected Properties |
defaults
The default values for keys not found in this Properties
instance. |
| Constructor Summary | |
|---|---|
Properties()
Constructs a new Properties object. |
|
Properties(Properties properties)
Constructs a new Properties object using the specified default
Properties. |
|
| Method Summary | |
|---|---|
String |
getProperty(String name)
Searches for the property with the specified name. |
String |
getProperty(String name,
String defaultValue)
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. |
void |
load(InputStream in)
Loads properties from the specified InputStream. |
void |
load(Reader in)
Loads properties from the specified Reader. |
void |
loadFromXML(InputStream in)
Loads the properties from an InputStream containing the
properties in XML form. |
Enumeration<?> |
propertyNames()
Returns all of the property names (keys) in this Properties object. |
void |
save(OutputStream out,
String comment)
Deprecated. This method ignores any IOException thrown while
writing -- use store(java.io.OutputStream, java.lang.String) instead for better exception
handling. |
Object |
setProperty(String name,
String value)
Maps the specified key to the specified value. |
void |
store(OutputStream out,
String comment)
Stores the mappings in this Properties object to out,
putting the specified comment at the beginning. |
void |
store(Writer writer,
String comment)
Stores the mappings in this Properties object to out,
putting the specified comment at the beginning. |
void |
storeToXML(OutputStream os,
String comment)
Writes all properties stored in this instance into the OutputStream in XML representation. |
void |
storeToXML(OutputStream os,
String comment,
String encoding)
Writes all properties stored in this instance into the OutputStream in XML representation. |
Set<String> |
stringPropertyNames()
Returns those property names (keys) in this Properties object for which
both key and value are strings. |
| Methods inherited from class java.util.Hashtable |
|---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Properties defaults
Properties
instance.
| Constructor Detail |
|---|
public Properties()
Properties object.
public Properties(Properties properties)
Properties object using the specified default
Properties.
properties - the default Properties.| Method Detail |
|---|
public String getProperty(String name)
Properties are checked. If the property is not
found in the default Properties, null is returned.
name - the name of the property to find.
null if it can't be found.
public String getProperty(String name,
String defaultValue)
Properties. If the property is not
found in the default Properties, it returns the specified
default.
name - the name of the property to find.defaultValue - the default value.
public void list(PrintStream out)
Properties to the specified
PrintStream in a
human readable form.
out - the PrintStream to write the content to in human readable
form.public void list(PrintWriter writer)
Properties to the specified
PrintWriter in a
human readable form.
writer - the PrintWriter to write the content to in human
readable form.
public void load(InputStream in)
throws IOException
InputStream. The encoding is
ISO-8859-1.
in - the InputStream
IOException
public void load(Reader in)
throws IOException
Reader.
The properties file is interpreted according to the following rules:
in - the Reader
IOExceptionpublic Enumeration<?> propertyNames()
Properties object.
public Set<String> stringPropertyNames()
Properties object for which
both key and value are strings.
@Deprecated
public void save(OutputStream out,
String comment)
IOException thrown while
writing -- use store(java.io.OutputStream, java.lang.String) instead for better exception
handling.
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(InputStream) method.
out - the OutputStream to write to.comment - the comment to add at the beginning.
ClassCastException - if the key or value of a mapping is not a
String.
public Object setProperty(String name,
String value)
null.
name - the key.value - the value.
null.
public void store(OutputStream out,
String comment)
throws IOException
Properties object to out,
putting the specified comment at the beginning. The encoding is
ISO-8859-1.
out - the OutputStreamcomment - an optional comment to be written, or null
IOException
ClassCastException - if a key or value is not a string
public void store(Writer writer,
String comment)
throws IOException
Properties object to out,
putting the specified comment at the beginning.
writer - the Writercomment - an optional comment to be written, or null
IOException
ClassCastException - if a key or value is not a string
public void loadFromXML(InputStream in)
throws IOException,
InvalidPropertiesFormatException
InputStream containing the
properties in XML form. The XML document must begin with (and conform to)
following DOCTYPE:
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">Also the content of the XML data must satisfy the DTD but the xml is not validated against it. The DTD is not loaded from the SYSTEM ID. After this method returns the InputStream is not closed.
in - the InputStream containing the XML document.
IOException - in case an error occurs during a read operation.
InvalidPropertiesFormatException - if the XML data is not a valid
properties file.
public void storeToXML(OutputStream os,
String comment)
throws IOException
OutputStream in XML representation. The DOCTYPE is
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">If the comment is null, no comment is added to the output. UTF-8 is used as the encoding. The
OutputStream is not closed at the end. A
call to this method is the same as a call to storeToXML(os,
comment, "UTF-8").
os - the OutputStream to write to.comment - the comment to add. If null, no comment is added.
IOException - if an error occurs during writing to the output.
public void storeToXML(OutputStream os,
String comment,
String encoding)
throws IOException
OutputStream in XML representation. The DOCTYPE is
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">If the comment is null, no comment is added to the output. The parameter
encoding defines which encoding should be used. The OutputStream is not closed at the end.
os - the OutputStream to write to.comment - the comment to add. If null, no comment is added.encoding - the code identifying the encoding that should be used to
write into the OutputStream.
IOException - if an error occurs during writing to the output.
|
Android 2.3 Gingerbread | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||