Skip to content

FileUtils.readFileToByteArray - optimize reading of files with known size#38

Closed
ilmarmors wants to merge 1 commit into
apache:masterfrom
ilmarmors:master
Closed

FileUtils.readFileToByteArray - optimize reading of files with known size#38
ilmarmors wants to merge 1 commit into
apache:masterfrom
ilmarmors:master

Conversation

@ilmarmors

@ilmarmors ilmarmors commented Jul 2, 2017

Copy link
Copy Markdown
Contributor

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

@coveralls

coveralls commented Jul 2, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.002%) to 90.071% when pulling 3ce1388 on ilmarmors:master into d4f28d7 on apache:master.

@PascalSchumacher

Copy link
Copy Markdown
Contributor

@asfgit asfgit closed this in 936b820 Jul 2, 2017
@PascalSchumacher

Copy link
Copy Markdown
Contributor

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants