[
https://issues.apache.org/jira/browse/IO-486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14994042#comment-14994042
]
Sebb commented on IO-486:
-------------------------
I'm not sure that is safe.
If the file is currently open and being updated, AFAIK some OSes may return 0
for the file length even if there is data in the file.
Sorry, but I don't think this is something we should implement.
If there is an app for which this is a worthwhile time saver - i.e. it reads
lots of files, most of which are empty - then it should do the checks itself.
> FileUtils.readFileToString() can immediately return empty string if file
> length is zero
> ---------------------------------------------------------------------------------------
>
> Key: IO-486
> URL: https://issues.apache.org/jira/browse/IO-486
> Project: Commons IO
> Issue Type: Improvement
> Reporter: Viktor Isaev
>
> If {{file.length() == 0}}, there is no point of doing extra work of opening
> and closing an input stream - we can return an empty string right away.
> Same applies for {{FileUtils.readFileToByteArray()}} and
> {{FileUtils.readLines()}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)