commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viktor Isaev (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-486) FileUtils.readFileToString() can immediately return empty string if file length is zero
Date Mon, 09 Nov 2015 14:47:11 GMT

    [ https://issues.apache.org/jira/browse/IO-486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996638#comment-14996638
] 

Viktor Isaev commented on IO-486:
---------------------------------

I'm not speaking against short-circuit in {{IOUtils.toByteArray()}} - I'm speaking for a similar
short-circuit in {{FileUtils.readFileToString()}} (and in {{FileUtils.readFileToByteArray()}}
where we are guaranteed to uselessly open and close a stream in this case).

Well, it's just a suggestion.

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

Mime
View raw message