Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-651

Provide method to retrieve data from DeferredFileOutputStream as InputStream

    XMLWordPrintableJSON

    Details

    • Flags:
      Patch

      Description

      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):

      public InputStream toInputStream() throws IOException {
          if (!closed) {
              throw new IOException("Stream not closed");
          }
      
          if (isInMemory()) {
              return memoryOutputStream.toInputStream();
          } else {
              return Files.newInputStream(outputFile.toPath());
          }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jmark John Mark
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 4h
                4h