2008/11/25 Wayne Fay <[EMAIL PROTECTED]>

>
> > load in my code with
> > "this.getClass().getClassLoader().getResource(...)". All resources are
>
> John Casey sent this method a while ago that might be useful:
>
> private File getFile( String resourceName )
> {
>  ClassLoader cloader = Thread.currentThread().getContextClassLoader();
>  URL resource = cloader.getResource( resourceName );
>  if ( resource == null )
>  {
>     throw new IllegalArgumentException( "Could not get resource: " +
> resourceName );
>  }
>  return new File( resource.getPath() );
> }
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

There are issues with that method and windows file paths that have spaces in
them.

AFAIR, it's better to do

return new File( resource.toURI() );

Reply via email to