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

FileUtils#readFileToByteArray: optimize reading of files with known size

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.6
    • None
    • None

    Description

      IO-251 added optimization for reading files with known size as byte arrays, but it was reverted in IO-453 due to regression, because File.length() method may return 0 for path files denoting system-dependent entities such as devices or pipes

      More optimal solution is to treat 0 as unknown size and use IOUtils.toByteArray(input), but if size is known (> 0) use more efficient approach and read content into pre-allocated byte array with exact size by calling IOUtils.toByteArray(input, size).

      source https://github.com/apache/commons-io/pull/38

      Attachments

        Activity

          People

            pascalschumacher Pascal Schumacher
            pascalschumacher Pascal Schumacher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: