Class DefaultPropertiesPersister
- All Implemented Interfaces:
- PropertiesPersister
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).
- Since:
- 10.03.2004
- Author:
- Juergen Hoeller, Sebastien Deleuze
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final DefaultPropertiesPersisterA convenient constant for a defaultDefaultPropertiesPersisterinstance, as used in Spring's common resource support.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidload(Properties props, InputStream is) Load properties from the given InputStream into the given Properties object.voidload(Properties props, Reader reader) Load properties from the given Reader into the given Properties object.voidloadFromXml(Properties props, InputStream is) Load properties from the given XML InputStream into the given Properties object.voidstore(Properties props, OutputStream os, String header) Write the contents of the given Properties object to the given OutputStream.voidstore(Properties props, Writer writer, String header) Write the contents of the given Properties object to the given Writer.voidstoreToXml(Properties props, OutputStream os, String header) Write the contents of the given Properties object to the given XML OutputStream.voidstoreToXml(Properties props, OutputStream os, String header, String encoding) Write the contents of the given Properties object to the given XML OutputStream.
- 
Field Details- 
INSTANCEA convenient constant for a defaultDefaultPropertiesPersisterinstance, as used in Spring's common resource support.- Since:
- 6.0
 
 
- 
- 
Constructor Details- 
DefaultPropertiesPersisterpublic DefaultPropertiesPersister()
 
- 
- 
Method Details- 
loadDescription copied from interface:PropertiesPersisterLoad properties from the given InputStream into the given Properties object.- Specified by:
- loadin interface- PropertiesPersister
- Parameters:
- props- the Properties object to load into
- is- the InputStream to load from
- Throws:
- IOException- in case of I/O errors
- See Also:
 
- 
loadDescription copied from interface:PropertiesPersisterLoad properties from the given Reader into the given Properties object.- Specified by:
- loadin interface- PropertiesPersister
- Parameters:
- props- the Properties object to load into
- reader- the Reader to load from
- Throws:
- IOException- in case of I/O errors
 
- 
storeDescription copied from interface:PropertiesPersisterWrite the contents of the given Properties object to the given OutputStream.- Specified by:
- storein interface- PropertiesPersister
- Parameters:
- props- the Properties object to store
- os- the OutputStream to write to
- header- the description of the property list
- Throws:
- IOException- in case of I/O errors
- See Also:
 
- 
storeDescription copied from interface:PropertiesPersisterWrite the contents of the given Properties object to the given Writer.- Specified by:
- storein interface- PropertiesPersister
- Parameters:
- props- the Properties object to store
- writer- the Writer to write to
- header- the description of the property list
- Throws:
- IOException- in case of I/O errors
 
- 
loadFromXmlDescription copied from interface:PropertiesPersisterLoad properties from the given XML InputStream into the given Properties object.- Specified by:
- loadFromXmlin interface- PropertiesPersister
- Parameters:
- props- the Properties object to load into
- is- the InputStream to load from
- Throws:
- IOException- in case of I/O errors
- See Also:
 
- 
storeToXmlDescription copied from interface:PropertiesPersisterWrite the contents of the given Properties object to the given XML OutputStream.- Specified by:
- storeToXmlin interface- PropertiesPersister
- Parameters:
- props- the Properties object to store
- os- the OutputStream to write to
- header- the description of the property list
- Throws:
- IOException- in case of I/O errors
- See Also:
 
- 
storeToXmlpublic void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException Description copied from interface:PropertiesPersisterWrite the contents of the given Properties object to the given XML OutputStream.- Specified by:
- storeToXmlin interface- PropertiesPersister
- Parameters:
- props- the Properties object to store
- os- the OutputStream to write to
- header- the description of the property list
- encoding- the encoding to use
- Throws:
- IOException- in case of I/O errors
- See Also:
 
 
-