directory question  
Author Message
<- Chameleon ->





PostPosted: 2005-4-15 4:05:00 Top

java-programmer, directory question 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!
 
HK





PostPosted: 2005-4-15 5:13:00 Top

java-programmer >> directory question <- Chameleon -> wrote:
> 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");
Try
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)

Harald.

 
Robert





PostPosted: 2005-4-15 9:28:00 Top

java-programmer >> directory question 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.

 
 
<- Chameleon ->





PostPosted: 2005-4-16 17:47:00 Top

java-programmer >> directory question > 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 ;-)