• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

Problem with class.getResourceAsStream

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try to load an xsl file with classLoader, but Test.class.getResourceAsStream("test.xsl") always returns null. Then i copied the test.xsl file to test.png - and that one works fine. Can anyone explain me how it can happen?

Here is the test case: two identical files with different extensions reside in the same package, and classloader works with different results:


The output is:
xsl: null
png: java.io.BufferedInputStream@3d84ec44


UPD: The problem found - i was lounching this from IDEA and it was misconfigured: Resource patterns setting included *png but didn't include *xsl
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic