You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benjamin Bentmann (JIRA)" <ji...@apache.org> on 2008/04/24 20:01:24 UTC

[jira] Commented: (IO-46) [io] Find file in classpath

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

Benjamin Bentmann commented on IO-46:
-------------------------------------

bq. What's the use case for this feature?
For example to place some input files on the test class path to fetch from when invoking File-based APIs.

> [io] Find file in classpath
> ---------------------------
>
>                 Key: IO-46
>                 URL: https://issues.apache.org/jira/browse/IO-46
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 1.1
>         Environment: Operating System: other
> Platform: Other
>            Reporter: David Leal
>            Priority: Minor
>             Fix For: 2.x
>
>
> Just to suggest adding a method like this: 
>  public File findFileInClasspath(String fileName) throws FileNotFoundException 
> {
>         URL url = getClass().getClassLoader().getResource(fileName);
>         if (url == null){
>             throw new FileNotFoundException(fileName);
>         }
>         return new File(url.getFile());
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.