4949import java .util .stream .Stream ;
5050import java .util .stream .StreamSupport ;
5151
52+ import org .apache .commons .io .Charsets ;
5253import org .apache .commons .io .build .AbstractStreamBuilder ;
5354import org .apache .commons .io .function .Uncheck ;
5455
@@ -305,15 +306,16 @@ public static Builder builder() {
305306 * @param file
306307 * a CSV file. Must not be null.
307308 * @param charset
308- * The Charset to decode the given file.
309+ * The Charset to decode the given file, {@code null} maps to the {@link Charset#defaultCharset() default Charset} .
309310 * @param format
310311 * the CSVFormat used for CSV parsing, {@code null} maps to {@link CSVFormat#DEFAULT}.
311312 * @return a new parser
312313 * @throws IllegalArgumentException
313- * If the parameters of the format are inconsistent or if either file or format are null .
314+ * If the parameters of the format are inconsistent.
314315 * @throws IOException
315316 * If an I/O error occurs
316- * @throws CSVException Thrown on invalid input.
317+ * @throws CSVException Thrown on invalid CSV input data.
318+ * @throws NullPointerException if {@code file} is {@code null}.
317319 */
318320 public static CSVParser parse (final File file , final Charset charset , final CSVFormat format ) throws IOException {
319321 Objects .requireNonNull (file , "file" );
@@ -331,20 +333,20 @@ public static CSVParser parse(final File file, final Charset charset, final CSVF
331333 * @param inputStream
332334 * an InputStream containing CSV-formatted input, {@code null} maps to {@link CSVFormat#DEFAULT}.
333335 * @param charset
334- * The Charset to decode the given file.
336+ * The Charset to decode the given file, {@code null} maps to the {@link Charset#defaultCharset() default Charset} .
335337 * @param format
336338 * the CSVFormat used for CSV parsing, {@code null} maps to {@link CSVFormat#DEFAULT}.
337339 * @return a new CSVParser configured with the given reader and format.
338340 * @throws IllegalArgumentException
339341 * If the parameters of the format are inconsistent or if either reader or format are null.
340342 * @throws IOException
341343 * If there is a problem reading the header or skipping the first record
342- * @throws CSVException Thrown on invalid input.
344+ * @throws CSVException Thrown on invalid CSV input data .
343345 * @since 1.5
344346 */
345347 public static CSVParser parse (final InputStream inputStream , final Charset charset , final CSVFormat format )
346348 throws IOException {
347- return parse (new InputStreamReader (inputStream , charset ), format );
349+ return parse (new InputStreamReader (inputStream , Charsets . toCharset ( charset ) ), format );
348350 }
349351
350352 /**
@@ -353,15 +355,16 @@ public static CSVParser parse(final InputStream inputStream, final Charset chars
353355 * @param path
354356 * a CSV file. Must not be null.
355357 * @param charset
356- * The Charset to decode the given file.
358+ * The Charset to decode the given file, {@code null} maps to the {@link Charset#defaultCharset() default Charset} .
357359 * @param format
358360 * the CSVFormat used for CSV parsing, {@code null} maps to {@link CSVFormat#DEFAULT}.
359361 * @return a new parser
360362 * @throws IllegalArgumentException
361- * If the parameters of the format are inconsistent or if either file or format are null .
363+ * If the parameters of the format are inconsistent.
362364 * @throws IOException
363365 * If an I/O error occurs
364- * @throws CSVException Thrown on invalid input.
366+ * @throws CSVException Thrown on invalid CSV input data.
367+ * @throws NullPointerException if {@code path} is {@code null}.
365368 * @since 1.5
366369 */
367370 @ SuppressWarnings ("resource" )
@@ -387,7 +390,7 @@ public static CSVParser parse(final Path path, final Charset charset, final CSVF
387390 * If the parameters of the format are inconsistent or if either reader or format are null.
388391 * @throws IOException
389392 * If there is a problem reading the header or skipping the first record
390- * @throws CSVException Thrown on invalid input.
393+ * @throws CSVException Thrown on invalid CSV input data .
391394 * @since 1.5
392395 */
393396 public static CSVParser parse (final Reader reader , final CSVFormat format ) throws IOException {
@@ -403,10 +406,11 @@ public static CSVParser parse(final Reader reader, final CSVFormat format) throw
403406 * the CSVFormat used for CSV parsing, {@code null} maps to {@link CSVFormat#DEFAULT}.
404407 * @return a new parser
405408 * @throws IllegalArgumentException
406- * If the parameters of the format are inconsistent or if either string or format are null .
409+ * If the parameters of the format are inconsistent.
407410 * @throws IOException
408411 * If an I/O error occurs
409- * @throws CSVException Thrown on invalid input.
412+ * @throws CSVException Thrown on invalid CSV input data.
413+ * @throws NullPointerException if {@code string} is {@code null}.
410414 */
411415 public static CSVParser parse (final String string , final CSVFormat format ) throws IOException {
412416 Objects .requireNonNull (string , "string" );
@@ -424,15 +428,16 @@ public static CSVParser parse(final String string, final CSVFormat format) throw
424428 * @param url
425429 * a URL. Must not be null.
426430 * @param charset
427- * the charset for the resource. Must not be null .
431+ * the charset for the resource, {@code null} maps to the {@link Charset#defaultCharset() default Charset} .
428432 * @param format
429433 * the CSVFormat used for CSV parsing, {@code null} maps to {@link CSVFormat#DEFAULT}.
430434 * @return a new parser
431435 * @throws IllegalArgumentException
432- * If the parameters of the format are inconsistent or if either url, charset or format are null .
436+ * If the parameters of the format are inconsistent.
433437 * @throws IOException
434438 * If an I/O error occurs
435- * @throws CSVException Thrown on invalid input.
439+ * @throws CSVException Thrown on invalid CSV input data.
440+ * @throws NullPointerException if {@code url} is {@code null}.
436441 */
437442 @ SuppressWarnings ("resource" )
438443 public static CSVParser parse (final URL url , final Charset charset , final CSVFormat format ) throws IOException {
@@ -484,7 +489,7 @@ public static CSVParser parse(final URL url, final Charset charset, final CSVFor
484489 * If the parameters of the format are inconsistent or if either reader or format are null.
485490 * @throws IOException
486491 * If there is a problem reading the header or skipping the first record
487- * @throws CSVException Thrown on invalid input.
492+ * @throws CSVException Thrown on invalid CSV input data .
488493 * @deprecated Will be removed in the next major version, use {@link Builder#get()}.
489494 */
490495 @ Deprecated
@@ -517,10 +522,9 @@ public CSVParser(final Reader reader, final CSVFormat format) throws IOException
517522 * @deprecated Will be private in the next major version, use {@link Builder#get()}.
518523 */
519524 @ Deprecated
520- public CSVParser (final Reader reader , final CSVFormat format , final long characterOffset , final long recordNumber )
521- throws IOException {
522- this (reader , format , characterOffset , recordNumber , null , false );
523- }
525+ public CSVParser (final Reader reader , final CSVFormat format , final long characterOffset , final long recordNumber ) throws IOException {
526+ this (reader , format , characterOffset , recordNumber , null , false );
527+ }
524528
525529 /**
526530 * Constructs a new instance using the given {@link CSVFormat}
@@ -546,7 +550,7 @@ public CSVParser(final Reader reader, final CSVFormat format, final long charact
546550 * If the parameters of the format are inconsistent or if either the reader or format is null.
547551 * @throws IOException
548552 * If there is a problem reading the header or skipping the first record.
549- * @throws CSVException Thrown on invalid input.
553+ * @throws CSVException Thrown on invalid CSV input data .
550554 */
551555 private CSVParser (final Reader reader , final CSVFormat format , final long characterOffset , final long recordNumber ,
552556 final Charset charset , final boolean trackBytes )
@@ -875,7 +879,7 @@ public Iterator<CSVRecord> iterator() {
875879 *
876880 * @return the record as an array of values, or {@code null} if the end of the stream has been reached.
877881 * @throws IOException on parse error or input read-failure.
878- * @throws CSVException on invalid input.
882+ * @throws CSVException on invalid CSV input data .
879883 */
880884 CSVRecord nextRecord () throws IOException {
881885 CSVRecord result = null ;
0 commit comments