| Author |
Relative path
|
Jessid Leon Velez Gutierrez
Greenhorn
Joined: Dec 04, 2006
Posts: 22
|
|
Hello. I have a question: I am creating an application that want to pack in a jar file. That app uses a couple of plain text files. I want to include thouse 2 files into the jar, but i havent been able to make the app to read them. I dont know how to doit. Perhaps some of you could help me please with that. Thanks a lot!
|
 |
Stevi Deter
Ranch Hand
Joined: Mar 22, 2008
Posts: 265
|
|
Jessid, In order to help you, we'll need some more detail. Where are you putting the file? What's the code that's trying to open it? What exception are you seeing (full stack trace helps)?
|
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
If he doesn't know how to do it, I don't think we need any more detail! To read files out of the jar a program is packed into, you can't use things like FileReader and FileInputStream. Instead, use the ClassLoader methods that find files along the classpath, like this: InputStream theFile = getClass().getResourceAsStream("thefile.txt");
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Relative path
|
|
|