• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Does Classloader loads normal files from dir in a JAR file

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naresh pokuri wrote:what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.


Yes, we can.
You could pack to jar file whatever you want - images, properties, icons, text files, other jars, even database files.
If you want to retrieve resources from your application's jar file, try this example:


If you want to read file from other jar, try this:

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

naresh pokuri wrote:what is the nature of Classloader, when a JAR file contains a dir named pref folder with .properties files and other xml files.
can we get reference to that files as stream by passing file names to ClassLoader.getReasourceAsStream() method.


Just for future reference, it would have been quicker to just try it!
 
reply
    Bookmark Topic Watch Topic
  • New Topic