This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 914ca791f6696be814d7a13d4135fc57f3adc25e Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Oct 7 12:20:36 2023 -0400 Revert "[IO-414] Don't write a BOM on every (or any) line #492" This reverts commit 33225fa2759163c61abdead4ae891b5e75e17fb9. --- src/changes/changes.xml | 5 +---- src/main/java/org/apache/commons/io/IOUtils.java | 7 +++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 44b5a96e..2cff287e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -71,10 +71,7 @@ The <action> type attribute can be add,update,fix,remove. StreamIterator fails to close its internal Stream. </action> <action dev="ggregory" type="fix" issue="IO-814" due-to="Elliotte Rusty Harold, Gary Gregory"> - Don't throw UncheckedIOException #491. - </action> - <action dev="ggregory" type="fix" issue="IO-414" due-to="Elliotte Rusty Harold, Gary Gregory"> - Don't write a BOM on every (or any) line #492. + Don't throw UncheckedIOException #491. </action> <!-- ADD --> <!-- UPDATE --> diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index dfc9ff57..3382e865 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -3828,11 +3828,10 @@ public class IOUtils { * Writes the {@link #toString()} value of each item in a collection to * an {@link OutputStream} line by line, using the specified character * encoding and the specified line ending. - * <p> + * * UTF-16 is written big-endian with no byte order mark. * For little endian, use UTF-16LE. For a BOM, write it to the stream * before calling this method. - * </p> * * @param lines the lines to write, null entries produce blank lines * @param lineEnding the line separator to use, null is system default @@ -3843,14 +3842,14 @@ public class IOUtils { * @since 2.3 */ public static void writeLines(final Collection<?> lines, String lineEnding, final OutputStream output, - final Charset charset) throws IOException { + final Charset charset) throws IOException { if (lines == null) { return; } if (lineEnding == null) { lineEnding = System.lineSeparator(); } - Charset cs = StandardCharsets.UTF_16.equals(Charsets.toCharset(charset)) ? StandardCharsets.UTF_16 : StandardCharsets.UTF_16BE; + Charset cs = Charsets.toCharset(charset); // don't write a BOM if (cs == StandardCharsets.UTF_16) { cs = StandardCharsets.UTF_16BE;