You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2021/02/22 20:07:00 UTC

[jira] [Comment Edited] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

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

Gary D. Gregory edited comment on IO-651 at 2/22/21, 8:06 PM:
--------------------------------------------------------------

Resolving for 2.9.0; thank you [~jmark]!

Please verify git master and close this ticket if all is well for your use case.

 

 


was (Author: garydgregory):
Resolving for 2.9.0; thank you [~jmark]!

 

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> ----------------------------------------------------------------------------
>
>                 Key: IO-651
>                 URL: https://issues.apache.org/jira/browse/IO-651
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 2.6
>            Reporter: John Mark
>            Priority: Major
>              Labels: easyfix, performance, pull-request-available
>             Fix For: 2.9.0
>
>          Time Spent: 4h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the {{DeferredFileOutputStream}} class. Besides for convenience, it would allow for improved efficiency since in the case of in-memory data the byte buffer would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
>     if (!closed) {
>         throw new IOException("Stream not closed");
>     }
>     if (isInMemory()) {
>         return memoryOutputStream.toInputStream();
>     } else {
>         return Files.newInputStream(outputFile.toPath());
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)