directory question

G

Guest

I have a file named "main.ini" in the directory of jar (self-executable
package)
When I run jar from its directory all ok
When I run jar from another directory it cannot found "main.ini"

I open "main.ini" with
InputStream is = new FileInputStream("main.ini");
but I understand I must open it with
InputStream is = new FileInputStream(getDirectoryOfJavaProgram() +
"main.ini");

can you implement
getDirectoryOfJavaProgram()???

thanks!
 
R

Robert

Are you seriously asking someone to write the whole method for you?
You so crazeh! Anyway yeah try puting the file in your runtime
classpath then use ClassLoader.getResourceAsStream() be sure to start
the specify the '/' in the filename.
 
G

Guest

Are you seriously asking someone to write the whole method for you?
You so crazeh!

No, but my english is not good, and I speak out better with code instead
of english ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top