修改JAR文件内的信息

huangapple go评论64阅读模式
英文:

Modify information inside jar file

问题

所以我的问题是关于用Java编写的程序。我创建了一个类似排行榜的前5名分数排行榜,使用一个文本文件为我的游戏。它读取已保存在文本文件中的前几名分数,当你完成游戏时,它会写入这个文本文件,然后读取它并更新游戏中显示的前几名分数。但现在我在将我的游戏打包成jar文件时遇到了问题。似乎在jar文件内部修改文本文件是不可能的...

那么在这里有哪些可能的解决方案呢?强制程序在jar文件所在路径创建新的文本文件是其中一个解决方案,但也许还有一些更简单的解决方案,不会在计算机上创建额外的文件。

英文:

so my question is about programm written in java. I created sort of top 5 scores ranking using a text file for my game. It reads top scores, that are already saved in a text file, and when you finish the game, it writes to this text file, then reads it and updates top scores shown in the game. But now i'm stuck in packaging my game to a jar file. It seems impossible to modify a text file inside a jar file...

So what are possible solutions here? Forcing a programm to create new text file in a path where jar file is is one of the solutions, but maybe there is some easier solution that won't create additional file on a computer.

答案1

得分: 1

我建议在与您的程序相关的某个位置存储一个外部文本文件。然后,让您的程序根据需要进行修改。

英文:

I would recommend having an external text file stored somewhere relative to your program. Then have your program modify it as it needs.

huangapple
  • 本文由 发表于 2020年4月7日 09:57:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/61071631.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定