i am developing a java application. I've got a txt file such like this:
Component(Journal, Account, AnalysisCodes...):
Journal
*****
Method(Query, Import, CreateOrAmend...):
Import
*****
Username:
PKP
*****
Password:
test
*****
Host:
localhost
*****
Port:
8080
*****
Program's path:
C:/Connect Manager/
*****
XML Name:
ledger.xml
*****
This java program does not write anything in this file, it just reads it. However i could not figure out where to store this txt file. Path must be same for every users since it is hard coded inside. I cannot read path of the program if i don't know the path of program.
Here is my code:
String lineconfig="";
String pathconfig= "C:/Connect Manager/" + "config.txt";
BufferedReader readerconfig= new BufferedReader(new FileReader(pathconfig));
while((lineconfig=readerconfig.readLine())!=null)
{
stringList.add(lineconfig);
}
readerconfig.close();
As you see, i need an exact location for pathconfig.
Sorry if i caused any confusion in question. I would appreciate your suggestions.
Besides that: Another program should be able to edit this or the user. I will make this program a jar.
pathconfigjust asconfig.txt.MyClass.class.getResourceAsStream("config.txt");then put it in same level as your class. Or, you could useSystem.getProperty("user.dir")URLinstead ofFile. See the info page for the tag, for a way to form anURL.