commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Behrang Saeedzadeh (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (IO-513) Add convenience methods for reading class path resources
Date Sat, 27 Aug 2016 05:40:20 GMT

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

Behrang Saeedzadeh edited comment on IO-513 at 8/27/16 5:39 AM:
----------------------------------------------------------------

Hi Gary,

Thanks for your feedback.

I think that NPE scenario is handled by these lines in {{resourceToURL}}:

{code}
        final URL resource = IOUtils.class.getResource(name);
        if (resource == null) {
            throw new IOException("Resource not found: " + name);
        }
{code}

Also other overloads delegate to {{resourceURL}} so they are covered too. Or is there another
potential for {{NPE}} that I am missing?

Regarding the best place for this method, I don't mind to move these methods if a better place
in the Commons is suggested, but {{IOUtils}} already has these methods (and more) that deal
with network IO:

* [closeQuietly(java.net.Socket)|https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#closeQuietly(java.net.Socket)]
* [closeQuietly(java.net.ServerSocket)|https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#closeQuietly(java.net.ServerSocket)]
* [toByteArray(java.net.URL)|https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#toByteArray(java.net.URL)]
* [toByteArray(java.net.URI)|https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#toByteArray(java.net.URI)]

So probably {{IOUtils}} is not a bad place for these {{resourceTo...}} methods after all.

Regards,
Behrang


was (Author: thorium):
Hi Gary,

Thanks for your feedback.

I think that NPE scenario is handled by these lines in {{resourceToURL}}:

{code}
        final URL resource = IOUtils.class.getResource(name);
        if (resource == null) {
            throw new IOException("Resource not found: " + name);
        }
{code}

Also other overloads delegate to {{resourceURL}} so they are covered too. Or is there another
potential for {{NPE}} that I am missing?

Regarding the best place for this method, I don't mind to move these methods if a better place
in the Commons is suggested, but {{IOUtils}} already has these methods (and more) that deal
with network IO:

* https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#closeQuietly(java.net.Socket)
* https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#closeQuietly(java.net.ServerSocket)
* https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#toByteArray(java.net.URL)
* https://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html#toByteArray(java.net.URI)

So probably {{IOUtils}} is not a bad place for these {{resourceTo...}} methods after all.

Regards,
Behrang

> 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