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-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new 31e00ad3 Use forEachOrdered()
31e00ad3 is described below

commit 31e00ad32da2c7a0e8506e407dca9dbc6de9e9c3
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Feb 3 13:03:11 2024 -0500

    Use forEachOrdered()
---
 src/main/java/org/apache/commons/csv/CSVPrinter.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java 
b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index 6d8f8af8..239744c9 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -259,10 +259,9 @@ public final class CSVPrinter implements Flushable, 
Closeable {
      * @throws IOException
      *             If an I/O error occurs
      */
+    @SuppressWarnings("resource")
     public synchronized void printRecord(final Iterable<?> values) throws 
IOException {
-        for (final Object value : values) {
-            print(value);
-        }
+        IOStream.of(values).forEachOrdered(this::print);
         println();
     }
 
@@ -352,10 +351,9 @@ public final class CSVPrinter implements Flushable, 
Closeable {
      * @throws IOException
      *             If an I/O error occurs
      */
+    @SuppressWarnings("resource")
     public void printRecords(final Iterable<?> values) throws IOException {
-        for (final Object value : values) {
-            printRecordObject(value);
-        }
+        IOStream.of(values).forEachOrdered(this::printRecordObject);
     }
 
     /**

Reply via email to