Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public class Properties

  1. Object
  2. Dictionary<Object, Object>
  3. Hashtable<Object, Object>
  4. Properties

ImplementsMap<Object, Object>

String keys and values, a second table of defaults behind them, and the .properties text format.

The format is read as the JDK reads it: # and ! comments, =, : or white space between key and value, a trailing backslash continuing a line (the next line’s indentation dropped), and the escapes \t, \n, \r, \f and backslash-u followed by four hexadecimal digits; a backslash before any other character stands for that character. A stream is ISO 8859-1; a reader is whatever its characters are. store writes text that load reads back to the same table, escaping what the format requires and, on a stream, every character outside printable ASCII.

The XML form (loadFromXML, storeToXML) and list are not provided.

Fields

protected Properties defaultsThe table consulted for a key this one does not have, or null.

Constructors

public Properties()An empty table with no defaults.
public Properties(Properties defaults)An empty table with defaults behind it.

Methods

public String getProperty(String name)The value for name here, else in the defaults, else null.
public String getProperty(String name, String defaultValue)The value for name as getProperty(String) finds it, or defaultValue when there is none.
public Object setProperty(String name, String value)Maps name to value in this table, answering the value it replaced.
public synchronized void load(InputStream in) throws IOExceptionReads ISO 8859-1 .properties text, adding to what is here.
public synchronized void load(Reader in) throws IOExceptionReads .properties text, adding to what is here.
public Enumeration<?> propertyNames()Every key of this table and of its defaults.
public Set<String> stringPropertyNames()The keys, of this table and of its defaults, whose key and value are both strings.
public void save(OutputStream out, String comments)Deprecated Writes this table as store(OutputStream, String) does, ignoring any IOException.
public void store(OutputStream out, String comments) throws IOExceptionWrites this table (not its defaults) as ISO 8859-1 .properties text: the comment lines, a line with the current date, then one key=value line per entry.
public void store(Writer writer, String comments) throws IOExceptionWrites this table as .properties text, leaving characters outside ASCII as they are.

Inherited nested types

Inherited methods

Field details

defaults

protected Properties defaults
The table consulted for a key this one does not have, or null.

Constructor details

Properties

public Properties()
An empty table with no defaults.

Properties

public Properties(Properties defaults)
An empty table with defaults behind it.

Method details

getProperty

public String getProperty(String name)
The value for name here, else in the defaults, else null. A value that is not a String counts as absent, as in the JDK.

getProperty

public String getProperty(String name, String defaultValue)
The value for name as getProperty(String) finds it, or defaultValue when there is none.

setProperty

public Object setProperty(String name, String value)
Maps name to value in this table, answering the value it replaced.

load

public synchronized void load(InputStream in) throws IOException
Reads ISO 8859-1 .properties text, adding to what is here. The stream is left open.

load

public synchronized void load(Reader in) throws IOException
Reads .properties text, adding to what is here. The reader is left open.

propertyNames

public Enumeration<?> propertyNames()
Every key of this table and of its defaults.

stringPropertyNames

public Set<String> stringPropertyNames()
The keys, of this table and of its defaults, whose key and value are both strings.

save

public void save(OutputStream out, String comments)
Deprecated. An error writing is lost; use store(OutputStream, String).
Writes this table as store(OutputStream, String) does, ignoring any IOException.

store

public void store(OutputStream out, String comments) throws IOException
Writes this table (not its defaults) as ISO 8859-1 .properties text: the comment lines, a line with the current date, then one key=value line per entry. The stream is flushed and left open.

Throws

ClassCastException
if a key or value is not a String
IOException

store

public void store(Writer writer, String comments) throws IOException
Writes this table as .properties text, leaving characters outside ASCII as they are. The writer is flushed and left open.

Throws

ClassCastException
if a key or value is not a String
IOException