commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-513) Add convenience methods for reading class path resources
Date Tue, 23 Aug 2016 14:50:20 GMT

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

Gary Gregory commented on IO-513:
---------------------------------

Hi All:

The current patch for {{resourceToString}} and {{resourceToByteArray}} will throw an {{NullPointerException}}
when the input is bogus. You should most likely detect the null value and throw an {{IllegalArgumentException}}.

I usually end up with the kind of code in this proposal somewhere in most of my projects.
But where does it belong in Commons? One could argue that the URL and URI APIs belong in Commons
Net.

The {{resourcesTo*}} methods I usually put in a {{ResourceUtils}} class and call them {{get<ReturnType>()}}
or {{readAs<ReturnType}}>; the {{to}} prefix is not appropriate IMO because you are
not _converting_ anything, you are reading from a resource. 

I also usually end up needing a variant that takes a {{ClassLoader}} so the resource can be
found in the right place in more complex use-cases.

Dealing with Charsets is a must in my day to day work, so I am not surprised when it shows
up in APIs. Relying on the default platform encoding is usually problematic when you are moving
files around different machines.

Gary

> Add convenience methods for reading class path resources
> --------------------------------------------------------
>
>                 Key: IO-513
>                 URL: https://issues.apache.org/jira/browse/IO-513
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>            Reporter: Behrang Saeedzadeh
>            Priority: Minor
>              Labels: beginner, features, github-import, newbie
>
> Add convenience methods to {{IOUtils}} for reading class path resources and returning
them as {{String}}, {{byte[]}}, and {{URL}} respectively.
> Github PR: https://github.com/apache/commons-io/pull/17



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message