Simplify conversion of ByteArrayOutputStream to String

Closes gh-24785
This commit is contained in:
Сергей Цыпанов
2020-03-26 10:54:40 +02:00
committed by Sam Brannen
parent 62c545d0ed
commit 65aa2d03f0
4 changed files with 6 additions and 7 deletions

View File

@@ -90,7 +90,7 @@ class SortedProperties extends Properties {
public void store(OutputStream out, @Nullable String comments) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
super.store(baos, (this.omitComments ? null : comments));
String contents = new String(baos.toByteArray(), StandardCharsets.ISO_8859_1);
String contents = baos.toString(StandardCharsets.ISO_8859_1.name());
for (String line : contents.split(EOL)) {
if (!(this.omitComments && line.startsWith("#"))) {
out.write((line + EOL).getBytes(StandardCharsets.ISO_8859_1));