Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
</project>
5 changes: 4 additions & 1 deletion src/main/java/org/codejive/properties/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@ public void store(Path file, String... comment) throws IOException {
* @throws IOException Thrown when any IO error occurs during operation
*/
public void store(OutputStream out, String... comment) throws IOException {
store(new OutputStreamWriter(out, StandardCharsets.ISO_8859_1), comment);
store(
new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.ISO_8859_1)),
comment);
}

/**
Expand Down Expand Up @@ -938,6 +940,7 @@ public void store(Writer writer, String... comment) throws IOException {
writer.write(pos.raw());
pos.next();
}
writer.flush();
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/codejive/properties/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ void testStore() throws IOException, URISyntaxException {
assertThat(sw.toString()).isEqualTo(readAll(f));
}

@Test
void testStoreOutputStream() throws IOException, URISyntaxException {
Path f = getResource("/test-escaped.properties");
Properties p = Properties.loadProperties(f);
ByteArrayOutputStream os = new ByteArrayOutputStream();
p.store(os);
assertThat(os.toString()).isEqualTo(readAll(f));
}

@Test
void testStoreCrLf() throws IOException, URISyntaxException {
Path f = getResource("/testcrlf.properties");
Expand Down