Commons IO
  1. Commons IO
  2. IO-251

Add new read method "toByteArray" to handle InputStream with known size

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.1
    • Component/s: Utilities
    • Labels:
      None

      Description

      I suggest adding a new method toByteArray(InputStream input, int size) to IoUtils to handle known size InputStream (e.g. files).
      Current implementation based on copy method consumes more memory than necessary (at least the double) to transform a InputStream into a byte array.

        Activity

        Marco Albini created issue -
        Hide
        Marco Albini added a comment -

        Added patch proposal file with:

        • New IOUtils method byte[] toByteArray(InputStream input, int size)
        • New IOUtils method byte[] toByteArray(InputStream input, long size)
        • Modified FileUtils method byte[] readFileToByteArray(File file)
        • Unit Test
        Show
        Marco Albini added a comment - Added patch proposal file with: New IOUtils method byte[] toByteArray(InputStream input, int size) New IOUtils method byte[] toByteArray(InputStream input, long size) Modified FileUtils method byte[] readFileToByteArray(File file) Unit Test
        Marco Albini made changes -
        Field Original Value New Value
        Attachment IO-251_toByteArray.patch [ 12456255 ]
        Mark Thomas made changes -
        Workflow jira [ 12522124 ] Default workflow, editable Closed status [ 12601888 ]
        Hide
        Sebb added a comment -

        Thanks, added to SVN

        Show
        Sebb added a comment - Thanks, added to SVN
        Sebb made changes -
        Fix Version/s 3.x [ 12312838 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.1 [ 12316027 ]
        Hide
        Gary Gregory added a comment -

        Closing, we released version 2.1.

        Show
        Gary Gregory added a comment - Closing, we released version 2.1.
        Gary Gregory made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Marco Albini
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development