Home

Javaproperties

Javaproperties refers to the Java properties mechanism, primarily implemented by the java.util.Properties class. It provides a simple, text-based way to store and retrieve a set of string key-value pairs, typically used for configuration data and localization strings in Java applications.

The standard properties file format uses plain text with lines containing key-value pairs. A line can use

Key APIs provided by java.util.Properties include:

- load(InputStream) and load(Reader) to read properties from a stream or reader.

- store(OutputStream, String) and store(Writer, String) to write properties with an optional comment.

- getProperty(String key) and setProperty(String key, String value), with getProperty also offering a default value variant.

- propertyNames() to enumerate keys, and methods to work with XML representations.

Encoding issues are a consideration: the standard .properties format uses ISO-8859-1 by default, with non-Latin characters

an
equals
sign
or
a
colon
as
a
separator,
and
whitespace
around
the
separator
is
ignored.
Lines
starting
with
the
character
#
or
!
are
comments.
Keys
and
values
can
include
spaces
and
special
characters,
which
are
represented
using
escape
sequences
(for
example,
\t,
\n,
\\,
and
Unicode
escapes
like
\uXXXX).
A
backslash
at
the
end
of
a
line
indicates
the
next
line
is
a
continuation.
In
addition
to
the
traditional
.properties
format,
Java
also
supports
an
XML
representation
of
properties
via
the
loadFromXML
and
storeToXML
methods.
escaped;
load(Reader)
and
XML
methods
offer
alternative
handling.
Although
widely
used
for
configuration,
for
internationalization
ResourceBundle
and
newer
configuration
approaches
are
commonly
employed
alongside
properties.