Re: protocol question
- From: "Rhino" <no.offline.contact.please@xxxxxxxxxx>
- Date: Sun, 30 Oct 2005 12:23:35 -0500
"Roedy Green" <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx> wrote in
message news:b7o8m1dvi0k9f7qvar5jqrj8n5a62u3h5t@xxxxxxxxxx
> On Sat, 29 Oct 2005 13:11:04 -0400, "Rhino"
> <no.offline.contact.please@xxxxxxxxxx> wrote, quoted or indirectly
> quoted someone who said :
>
> >I'm looking for a notation that I can use in my programs to refer to
files
> >that are within jars that are visible to the program by virtue of being
on
> >the program's classpath. In that case, the name of the jar isn't
necessary
> >since all jars in the classpath will be scanned for the file. That's why
I
> >was thinking that 'jar:file:!/images/foo.png' would be good since it
> >imitates the first example and implies that the file is in the file
system
> >but that we don't care what jar contains the file.
>
> getResource does searching and gives you the FIRST resource match on
> the classpath.
>
> It produces the !syntax which is treated thereafter like any other
> URL.
>
> You want a method something like this off the top of my head:
>
> /**
> @param s either resource or URL to resource
> code either as "myimage.jpg"
> or as "jar:file:///C|/bar/baz.jar!/com/foo/myimage.jpg"
> @eturn URL to resource
> */
> getURLForResource( Class c, String s )
> {
> if ( s.startsWith( "jar:" )
> || s.startsWith( "file:" )
> || s.startsWith( "http:" ) )
> return new URL( s );
> else return c.getResource( s );
> }
You might be on to something there! Hmm, let me think that over a bit....
Rhino
.
- References:
- Jar: protocol question
- From: Rhino
- Re: protocol question
- From: Ben_
- Re: protocol question
- From: Roedy Green
- Jar: protocol question
- Prev by Date: Re: protocol question
- Next by Date: Re: protocol question
- Previous by thread: Re: protocol question
- Next by thread: Re: protocol question
- Index(es):
Relevant Pages
|