A library for reading and writing Java properties files in Rust
  • Rust 97.6%
  • Shell 2.4%
Find a file
History 2024-07-26 13:18:22 +08:00
git-hooks Add git pre-commit hook and format the code 2023-05-19 20:56:49 -07:00
src Add unicode feature to switch between regex and regex-lite dep 2024-07-26 13:18:22 +08:00
.gitattributes Fix whitespace settings in .gitattributes 2016-04-07 20:38:01 -07:00
.gitignore Initial commit 2016-01-15 19:29:18 -08:00
Cargo.toml Add unicode feature to switch between regex and regex-lite dep 2024-07-26 13:18:22 +08:00
init-git-hooks Add git pre-commit hook and format the code 2023-05-19 20:56:49 -07:00
LICENSE Add LICENSE 2016-01-28 18:32:53 -08:00
README.md Use simple example in README.md 2017-09-07 18:00:28 -07:00

Java properties for Rust

This is a library for reading and writing Java properties files in Rust. The specification is taken from the Properties documentation. Where the documentation is ambiguous or incomplete, behavior is based on the behavior of java.util.Properties.

Example

use std::collections::HashMap;
use std::env::temp_dir;
use std::fs::File;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::prelude::*;

let mut file_name = temp_dir();
file_name.push("java-properties-test.properties");

// Writing
let mut map1 = HashMap::new();
map1.insert("a".to_string(), "b".to_string());
let mut f = File::create(&file_name)?;
write(BufWriter::new(f), &map1)?;

// Reading
let mut f = File::open(&file_name)?;
let map2 = read(BufReader::new(f))?;
assert_eq!(src_map1, dst_map1);