Struct java_properties::PropertiesWriter
source · pub struct PropertiesWriter<W: Write> { /* private fields */ }
Expand description
Writes to a properties file.
finish()
must be called after writing all data.
Implementations§
source§impl<W: Write> PropertiesWriter<W>
impl<W: Write> PropertiesWriter<W>
sourcepub fn new_with_encoding(writer: W, encoding: &'static Encoding) -> Self
pub fn new_with_encoding(writer: W, encoding: &'static Encoding) -> Self
Writes to the given Write
stream in the given encoding.
Note that the Java properties specification specifies ISO-8859-1 encoding
for properties files; in most cases, new
should be called instead.
sourcepub fn write_comment(&mut self, comment: &str) -> Result<(), PropertiesError>
pub fn write_comment(&mut self, comment: &str) -> Result<(), PropertiesError>
Writes a comment to the file.
sourcepub fn write(&mut self, key: &str, value: &str) -> Result<(), PropertiesError>
pub fn write(&mut self, key: &str, value: &str) -> Result<(), PropertiesError>
Writes a key/value pair to the file.
sourcepub fn flush(&mut self) -> Result<(), PropertiesError>
pub fn flush(&mut self) -> Result<(), PropertiesError>
Flushes the underlying stream.
sourcepub fn set_comment_prefix(
&mut self,
prefix: &str
) -> Result<(), PropertiesError>
pub fn set_comment_prefix( &mut self, prefix: &str ) -> Result<(), PropertiesError>
Sets the comment prefix.
The prefix must contain a ‘#’ or a ‘!’, may only contain spaces, tabs, or form feeds before the comment character, and may not contain any carriage returns or line feeds (‘\r’ or ‘\n’).
sourcepub fn set_kv_separator(
&mut self,
separator: &str
) -> Result<(), PropertiesError>
pub fn set_kv_separator( &mut self, separator: &str ) -> Result<(), PropertiesError>
Sets the key/value separator.
The separator may be non-empty whitespace, or a colon with optional whitespace on either side, or an equals sign with optional whitespace on either side. (Whitespace here means ’ ’, ‘\t’, or ‘\f’.)
sourcepub fn set_line_ending(&mut self, line_ending: LineEnding)
pub fn set_line_ending(&mut self, line_ending: LineEnding)
Sets the line ending.
sourcepub fn finish(&mut self) -> Result<(), PropertiesError>
pub fn finish(&mut self) -> Result<(), PropertiesError>
Finishes the encoding.