Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 61129200B56 for ; Sat, 30 Jul 2016 20:02:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5F82D160A8A; Sat, 30 Jul 2016 18:02:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A7A47160A63 for ; Sat, 30 Jul 2016 20:02:21 +0200 (CEST) Received: (qmail 4514 invoked by uid 500); 30 Jul 2016 18:02:20 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 4502 invoked by uid 99); 30 Jul 2016 18:02:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Jul 2016 18:02:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 71A892C027F for ; Sat, 30 Jul 2016 18:02:20 +0000 (UTC) Date: Sat, 30 Jul 2016 18:02:20 +0000 (UTC) From: "Gary Gregory (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CSV-189) CSVParser: Add factory method accepting InputStream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 30 Jul 2016 18:02:22 -0000 [ https://issues.apache.org/jira/browse/CSV-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15400760#comment-15400760 ] Gary Gregory edited comment on CSV-189 at 7/30/16 6:01 PM: ----------------------------------------------------------- I added a variation of your request (see below). Please verify and fix. {code:java} /** * Creates a CSV parser using the given {@link CSVFormat}. * *

* If you do not read all records from the given {@code reader}, you should * call {@link #close()} on the parser, unless you close the {@code reader}. *

* * @param reader * a Reader containing CSV-formatted input. Must not be null. * @param charsetName * The name of a supported {@link java.nio.charset.Charset * charset} * @param format * the CSVFormat used for CSV parsing. Must not be null. * @throws IllegalArgumentException * If the parameters of the format are inconsistent or if either * reader or format are null. * @throws UnsupportedEncodingException * If the named charset is not supported * @throws IOException * If there is a problem reading the header or skipping the * first record * @since 1.5 */ @SuppressWarnings("resource") public static CSVParser parse(final InputStream inputStream, final String charset, final CSVFormat format) throws IOException {code} was (Author: garydgregory): I added a variation of your request: {code:java} /** * Creates a CSV parser using the given {@link CSVFormat}. * *

* If you do not read all records from the given {@code reader}, you should * call {@link #close()} on the parser, unless you close the {@code reader}. *

* * @param reader * a Reader containing CSV-formatted input. Must not be null. * @param charsetName * The name of a supported {@link java.nio.charset.Charset *
charset} * @param format * the CSVFormat used for CSV parsing. Must not be null. * @throws IllegalArgumentException * If the parameters of the format are inconsistent or if either * reader or format are null. * @throws UnsupportedEncodingException * If the named charset is not supported * @throws IOException * If there is a problem reading the header or skipping the * first record * @since 1.5 */ @SuppressWarnings("resource") public static CSVParser parse(final InputStream inputStream, final String charset, final CSVFormat format) throws IOException {code} > CSVParser: Add factory method accepting InputStream > --------------------------------------------------- > > Key: CSV-189 > URL: https://issues.apache.org/jira/browse/CSV-189 > Project: Commons CSV > Issue Type: Improvement > Components: Parser > Affects Versions: 1.4 > Environment: all > Reporter: Peter Holzwarth > Priority: Trivial > Original Estimate: 1h > Remaining Estimate: 1h > > Please supply a CSVParser.parse operation accepting an InputStream, e.g. > {code:java} > public static CSVParser parse(InputStream stream, final CSVFormat format) throws IOException { > Assertions.notNull(stream, "stream"); > Assertions.notNull(format, "format"); > return new CSVParser(new InputStreamReader(stream), format); > } > {code} > This can be used more widely than File or String, and helps reading from resources (getClassLoader().getResourceAsStream()). -- This message was sent by Atlassian JIRA (v6.3.4#6332)