Posted By

resurge on 12/14/08


Tagged

file java text jar stream reader getResourceAsStream


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

appx
tartar9
jprobichaud


Read files from jar (getResourceAsStream) 2


 / Published in: Java
 

URL: http://www.java-tips.org/java-me-tips/midp/how-to-read-a-resource-from-a-jar-file.html

Found an easier way to read files from an executable jar than my other snippet.

The '/' is what tells java to go looking in the jar that's running instead of outside of it.

  1. Scanner scanner = new Scanner(getClass().getResourceAsStream("/" + path_to_file));

Report this snippet  

You need to login to post a comment.