Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #20100

Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()

Newsgroups comp.lang.java.programmer
Date 2012-12-04 12:57 -0800
References <3c227741-7b7f-4cf8-b188-ce5268894031@googlegroups.com> <26be3f32-1a52-4289-a7da-5d0e72427abd@googlegroups.com>
Message-ID <fcf8fbd2-e3ad-45a8-b04f-00a2c73e900c@googlegroups.com> (permalink)
Subject Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream()
From Lew <lewbloch@gmail.com>

Show all headers | View raw


zyng wrote:
> I have gone through the ClassLoader API doc
(http://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getSystemResource(java.lang.String))
> several times and still don't get a clue about it.

Gee, less than five minutes' online search turned up this link:
http://littletutorials.com/2008/03/26/locating-resources-in-java/

Did that article's assertions check out for you?

> This post cited ClassLoader API(http://www.xyzws.com/Servletfaq/what-is-different-between-classloadergetresourceasstream-and-classgetresourceasstream/21).
> However, in the API doc, I cannot find any information about leading slash. I guess Sun(or Oracle) has modified the API for new version. 

You guess based on what? There has to be *evidence* of such a change to make such a claim.

> Anyway, I cannot get the answer from ClassLoader API.

That does seem to be a hole in the API docs, but surely you have your answer by now.

> I found this post which has answered me most part:
> http://www.dtumanov.com/post/3355401249/java-resource-loading

In the end, a quick-and-dirty code example will answer your questions for you.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() zyng <xsli2@yahoo.com> - 2012-12-03 11:29 -0800
  Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() markspace <-@.> - 2012-12-03 12:07 -0800
    Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-03 14:04 -0800
      Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() markspace <-@.> - 2012-12-03 15:25 -0800
        Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-03 20:37 -0800
  Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() zyng <xsli2@yahoo.com> - 2012-12-04 05:40 -0800
    Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() Lew <lewbloch@gmail.com> - 2012-12-04 12:57 -0800

csiph-web