public class DefaultPropertiesPersister extends Object
java.util.Properties native parsing.
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 lacks: You can only 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.
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 use 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).
Properties,
Properties.load(java.io.Reader),
Properties.store(java.io.Writer, java.lang.String)| Constructor and Description |
|---|
DefaultPropertiesPersister() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
endsWithContinuationMarker(String line) |
protected String |
escape(String str,
boolean isKey) |
void |
load(Properties props,
InputStream is) |
void |
load(Properties props,
Reader reader) |
void |
store(Properties props,
OutputStream os,
String header) |
void |
store(Properties props,
Writer writer,
String header) |
void |
store(Properties props,
Writer writer,
String header,
boolean omitDate) |
protected String |
unescape(String str) |
public void load(Properties props, InputStream is) throws IOException
IOExceptionpublic void load(Properties props, Reader reader) throws IOException
IOExceptionprotected boolean endsWithContinuationMarker(String line)
public void store(Properties props, OutputStream os, String header) throws IOException
IOExceptionpublic void store(Properties props, Writer writer, String header) throws IOException
IOExceptionpublic void store(Properties props, Writer writer, String header, boolean omitDate) throws IOException
IOExceptionCopyright © 2005–2021 Atlassian. All rights reserved.