Received: by 10.66.72.134 with SMTP id d6mr2608561pav.20.1354654635080; Tue, 04 Dec 2012 12:57:15 -0800 (PST) Received: by 10.50.207.42 with SMTP id lt10mr1734483igc.6.1354654635039; Tue, 04 Dec 2012 12:57:15 -0800 (PST) Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.ripco.com!rahul.net!wasp.rahul.net!rahul.net!news.kjsl.com!usenet.stanford.edu!kt20no5608470pbb.1!news-out.google.com!6ni25806pbd.1!nntp.google.com!kr7no4767974pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Tue, 4 Dec 2012 12:57:14 -0800 (PST) In-Reply-To: <26be3f32-1a52-4289-a7da-5d0e72427abd@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <3c227741-7b7f-4cf8-b188-ce5268894031@googlegroups.com> <26be3f32-1a52-4289-a7da-5d0e72427abd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: ClassLoader.getSystemResourceAsStream versus this.getClass().getResourceAsStream() From: Lew Injection-Date: Tue, 04 Dec 2012 20:57:15 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:20100 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