commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-381) Add FileUtils.copyInputStreamToFile API with option to leave the source open
Date Wed, 08 May 2013 14:33:17 GMT

    [ https://issues.apache.org/jira/browse/IO-381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13651935#comment-13651935
] 

Sebb commented on IO-381:
-------------------------

Alternatively create a new method by analogy with copyFile(File, OutputStream), for example

copyToFile(InputStream, File)

Given that the existing method exists, not sure there is much point having a new public method
that exposes both old and new behaviours - there's no need for the end user to ever use closeSource=true
as there is already an API for that.

Of course we can choose to implement the two behaviours by delegating to a single private
method with the boolean parameter.
                
> Add FileUtils.copyInputStreamToFile API with option to leave the source open
> ----------------------------------------------------------------------------
>
>                 Key: IO-381
>                 URL: https://issues.apache.org/jira/browse/IO-381
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>         Environment: Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19
08:51:28-0500)
> Maven home: C:\Java\apache-maven-3.0.5\bin\..
> Java version: 1.7.0_17, vendor: Oracle Corporation
> Java home: C:\Program Files\Java\jdk1.7.0_17\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 2.5
>
>
> Add the API: {{copyInputStreamToFile(final InputStream source, final File destination,
boolean closeSource)}}
> {code:java}
>     /**
>      * Copies bytes from an {@link InputStream} <code>source</code> to a
file
>      * <code>destination</code>. The directories up to <code>destination</code>
>      * will be created if they don't already exist. <code>destination</code>
>      * will be overwritten if it already exists.
>      *
>      * @param source  the <code>InputStream</code> to copy bytes from, must
not be {@code null}, will be closed
>      * @param destination  the non-directory <code>File</code> to write bytes
to
>      *  (possibly overwriting), must not be {@code null}
>      * @param closeSource If true, closes the <code>source</code>
>      * @throws IOException if <code>destination</code> is a directory
>      * @throws IOException if <code>destination</code> cannot be written
>      * @throws IOException if <code>destination</code> needs creating but
can't be
>      * @throws IOException if an IO error occurs during copying
>      * @since 2.5
>      */
>     public static void copyInputStreamToFile(final InputStream source, final File destination,
boolean closeSource) 
>             throws IOException {
> {code}
> Related to [IO-380].

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message