reading a file that is inside the main .jar
I have made a little program that reads data from a file line per line. Now I want to join all the class files together with that file in one single jar file. The problem that I have with the jar is that java will look for 'my database' outside of the jar :( How can I make it look for it in the jar?
This is a piece of my code:
Code:
try{
FileReader frd = new FileReader("NL-FR");
BufferedReader brd = new BufferedReader(frd);
boolean finished = false;
String strLine = new String();
while (!finished){
strLine = brd.readLine();
if (strLine == null)
finished = true;
else{
/*
* Here a map with the original word as key
* and the possible translations as values
* The keys are then put seperately in an array
*/
String[] strAnswers = strLine.split(";");
String strKey = strAnswers[0];
String[] strValues = new String[strAnswers.length - 1];
for (byte i = 0; i < strAnswers.length - 1; i++){
strValues[i] = strAnswers[i+1];
}
mapDictionary.put(strKey,strValues);
}
}
}catch(IOException e){
lblCorrect.setText("ERROR: while reading file...");
}
Set<String> set = mapDictionary.keySet();
strQuestions = new String[set.size()];
set.toArray(strQuestions);