Top Description Fields Constructors Methods
org.springframework.util

public Class DefaultPropertiesPersister

extends Object
implements PropertiesPersister
Class Inheritance
All Implemented Interfaces
org.springframework.util.PropertiesPersister
Imports
java.io.IOException, .InputStream, .OutputStream, .Reader, .Writer, java.util.Properties

Default implementation of the PropertiesPersister interface. Follows the native parsing of java.util.Properties.

Allows for reading from any Reader and writing to any Writer, for example to specify a charset for a properties file. This is a capability that standard java.util.Properties unfortunately lacked up until JDK 5: You were only able to load files using the ISO-8859-1 charset there.

Loading from and storing to a stream delegates to Properties.load and Properties.store, respectively, to be fully compatible with the Unicode conversion as implemented by the JDK Properties class. As of JDK 6, Properties.load/store is also used for readers/writers, effectively turning this class into a plain backwards compatibility adapter.

The persistence code that works with Reader/Writer follows the JDK's parsing strategy but does not implement Unicode conversion, because the Reader/Writer should already apply proper decoding/encoding of characters. If you prefer to escape unicode characters in your properties files, do not specify an encoding for a Reader/Writer (like ReloadableResourceBundleMessageSource's "defaultEncoding" and "fileEncodings" properties).

Authors
Juergen Hoeller, Sebastien Deleuze
Since
10.03.2004
See Also
java.util.Properties, java.util.Properties#load, java.util.Properties#store

Field Summary

Modifier and TypeField and Description
public static final DefaultPropertiesPersister
INSTANCE

A convenient constant for a default DefaultPropertiesPersister instance, as used in Spring's common resource support.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
load(Properties
the Properties object to load into
props
,
InputStream
the InputStream to load from
is
)

Implements org.springframework.util.PropertiesPersister.load.

Load properties from the given InputStream into the given Properties object.
public void
load(Properties
the Properties object to load into
props
,
Reader
the Reader to load from
reader
)

Implements org.springframework.util.PropertiesPersister.load.

Load properties from the given Reader into the given Properties object.
public void
loadFromXml(Properties
the Properties object to load into
props
,
InputStream
the InputStream to load from
is
)

Implements org.springframework.util.PropertiesPersister.loadFromXml.

Load properties from the given XML InputStream into the given Properties object.
public void
store(Properties
the Properties object to store
props
,
OutputStream
the OutputStream to write to
os
,
String
the description of the property list
header
)

Implements org.springframework.util.PropertiesPersister.store.

Write the contents of the given Properties object to the given OutputStream.
public void
store(Properties
the Properties object to store
props
,
Writer
the Writer to write to
writer
,
String
the description of the property list
header
)

Implements org.springframework.util.PropertiesPersister.store.

Write the contents of the given Properties object to the given Writer.
public void
storeToXml(Properties
the Properties object to store
props
,
OutputStream
the OutputStream to write to
os
,
String
the description of the property list
header
)

Implements org.springframework.util.PropertiesPersister.storeToXml.

Write the contents of the given Properties object to the given XML OutputStream.
public void
storeToXml(Properties
the Properties object to store
props
,
OutputStream
the OutputStream to write to
os
,
String
the description of the property list
header
,
String
the encoding to use
encoding
)

Implements org.springframework.util.PropertiesPersister.storeToXml.

Write the contents of the given Properties object to the given XML OutputStream.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final DefaultPropertiesPersister INSTANCE

A convenient constant for a default DefaultPropertiesPersister instance, as used in Spring's common resource support.

Since
6.0

Constructor Detail

DefaultPropertiesPersisterback to summary
public DefaultPropertiesPersister()

Method Detail

loadback to summary
public void load(Properties props, InputStream is) throws IOException

Implements org.springframework.util.PropertiesPersister.load.

Doc from org.springframework.util.PropertiesPersister.load.

Load properties from the given InputStream into the given Properties object.

Parameters
props:Properties

the Properties object to load into

is:InputStream

the InputStream to load from

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
loadback to summary
public void load(Properties props, Reader reader) throws IOException

Implements org.springframework.util.PropertiesPersister.load.

Doc from org.springframework.util.PropertiesPersister.load.

Load properties from the given Reader into the given Properties object.

Parameters
props:Properties

the Properties object to load into

reader:Reader

the Reader to load from

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
loadFromXmlback to summary
public void loadFromXml(Properties props, InputStream is) throws IOException

Implements org.springframework.util.PropertiesPersister.loadFromXml.

Doc from org.springframework.util.PropertiesPersister.loadFromXml.

Load properties from the given XML InputStream into the given Properties object.

Parameters
props:Properties

the Properties object to load into

is:InputStream

the InputStream to load from

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
storeback to summary
public void store(Properties props, OutputStream os, String header) throws IOException

Implements org.springframework.util.PropertiesPersister.store.

Doc from org.springframework.util.PropertiesPersister.store.

Write the contents of the given Properties object to the given OutputStream.

Parameters
props:Properties

the Properties object to store

os:OutputStream

the OutputStream to write to

header:String

the description of the property list

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
storeback to summary
public void store(Properties props, Writer writer, String header) throws IOException

Implements org.springframework.util.PropertiesPersister.store.

Doc from org.springframework.util.PropertiesPersister.store.

Write the contents of the given Properties object to the given Writer.

Parameters
props:Properties

the Properties object to store

writer:Writer

the Writer to write to

header:String

the description of the property list

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
storeToXmlback to summary
public void storeToXml(Properties props, OutputStream os, String header) throws IOException

Implements org.springframework.util.PropertiesPersister.storeToXml.

Doc from org.springframework.util.PropertiesPersister.storeToXml.

Write the contents of the given Properties object to the given XML OutputStream.

Parameters
props:Properties

the Properties object to store

os:OutputStream

the OutputStream to write to

header:String

the description of the property list

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
storeToXmlback to summary
public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException

Implements org.springframework.util.PropertiesPersister.storeToXml.

Doc from org.springframework.util.PropertiesPersister.storeToXml.

Write the contents of the given Properties object to the given XML OutputStream.

Parameters
props:Properties

the Properties object to store

os:OutputStream

the OutputStream to write to

header:String

the description of the property list

encoding:String

the encoding to use

Annotations
@Override
Exceptions
IOException:
in case of I/O errors