I would like to write a file into Java archive (JAR). What do I need to modify in my code?
private void menu_savegame(ActionEvent e) {
File config = new File("config");
try {
FileWriter fw = new FileWriter(config);
fw.append(Integer.toString(level.current));
fw.append("\n");
if (win){
fw.append(Integer.toString(ballCount));
}
else{
fw.append(Integer.toString(G));
}
fw.append("\n");
fw.append(Integer.toString(liveLeft));
fw.flush();
} catch (IOException e1) {
e1.printStackTrace();
}
}
I just would like this file to be written not to the folder, but into the Game.jar file - I have there all the game resources (images).
Dont forget that JAR is a typical ZIP file. In provided link you can see how it is performed.
eventually, use external libraries like JBoss ShrinkWrap.
good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.