commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CSV-189) CSVParser: Add factory method accepting InputStream
Date Sat, 30 Jul 2016 18:01:20 GMT

     [ https://issues.apache.org/jira/browse/CSV-189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gary Gregory resolved CSV-189.
------------------------------
    Resolution: Fixed

I added a variation of your request: 
{code:java}
    /**
     * Creates a CSV parser using the given {@link CSVFormat}.
     *
     * <p>
     * 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}.
     * </p>
     *
     * @param reader
     *            a Reader containing CSV-formatted input. Must not be null.
     * @param charsetName
     *            The name of a supported {@link java.nio.charset.Charset
     *            </code>charset<code>}
     * @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)

Mime
View raw message