File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151 <groupId >commons-io</groupId >
5252 <artifactId >commons-io</artifactId >
5353 <version >2.14.0</version >
54- <scope >test</scope >
5554 </dependency >
5655 <dependency >
5756 <groupId >org.apache.commons</groupId >
Original file line number Diff line number Diff line change 4848import java .util .Objects ;
4949import java .util .Set ;
5050
51+ import org .apache .commons .io .IOUtils ;
52+
5153/**
5254 * Specifies the format of a CSV file for parsing and writing.
5355 *
Original file line number Diff line number Diff line change 4747import java .util .stream .Stream ;
4848import java .util .stream .StreamSupport ;
4949
50+ import org .apache .commons .io .function .Uncheck ;
51+
5052/**
5153 * Parses CSV files according to the specified format.
5254 *
@@ -144,11 +146,7 @@ class CSVRecordIterator implements Iterator<CSVRecord> {
144146 private CSVRecord current ;
145147
146148 private CSVRecord getNextRecord () {
147- try {
148- return CSVParser .this .nextRecord ();
149- } catch (final IOException e ) {
150- throw new UncheckedIOException ("Exception reading next record: " + e .toString (), e );
151- }
149+ return Uncheck .get (CSVParser .this ::nextRecord );
152150 }
153151
154152 @ Override
Original file line number Diff line number Diff line change 7070 */
7171public final class CSVPrinter implements Flushable , Closeable {
7272
73+ /**
74+ * Throws the given throwable.
75+ *
76+ * @param <T> The throwable cast type.
77+ * @param throwable The throwable to rethrow.
78+ * @return nothing because we throw.
79+ * @throws T Always thrown.
80+ */
81+ @ SuppressWarnings ("unchecked" )
82+ private static <T extends Throwable > RuntimeException rethrow (final Throwable throwable ) throws T {
83+ throw (T ) throwable ;
84+ }
85+
7386 /** The place that the values get written. */
7487 private final Appendable appendable ;
7588
@@ -300,7 +313,7 @@ public synchronized void printRecord(final Stream<?> values) throws IOException
300313 try {
301314 print (t );
302315 } catch (final IOException e ) {
303- throw IOUtils . rethrow (e );
316+ throw rethrow (e );
304317 }
305318 });
306319 println ();
@@ -489,7 +502,7 @@ public void printRecords(final Stream<?> values) throws IOException {
489502 try {
490503 printRecordObject (t );
491504 } catch (final IOException e ) {
492- throw IOUtils . rethrow (e );
505+ throw rethrow (e );
493506 }
494507 });
495508 }
Load diff This file was deleted.
Original file line number Diff line number Diff line change 6161import java .util .stream .Stream ;
6262
6363import org .apache .commons .io .FileUtils ;
64+ import org .apache .commons .io .IOUtils ;
6465import org .apache .commons .io .output .NullOutputStream ;
6566import org .apache .commons .lang3 .StringUtils ;
6667import org .h2 .tools .SimpleResultSet ;
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments