简体   繁体   English

在Java游戏中隐藏分数文件

[英]Hide score file in java game

I made a Java game and it records the high scores in a .dat file, then I converted the game into an .exe file. 我制作了一个Java游戏,它在.dat文件中记录了高分,然后将游戏转换为.exe文件。 However, when I play the .exe file and it records the score, the highscores.dat appears in whatever directory the .exe is located. 但是,当我播放.exe文件并记录分数时, highscores.dat出现在.exe所在的任何目录中。 I'm not very familiar with files processing in java aside from creating and reading them using the basic input streams and output streams. 除了使用基本输入流和输出流创建和读取文件外,我对Java中的文件处理不是很熟悉。 Is there any way to hide the score file so that if I give the game to someone the highscores.dat won't appear in their computer? 有什么方法可以隐藏分数文件,以便如果我将游戏交给某人, highscores.dat不会出现在他们的计算机中?

  • On Windows you could store your file in the %appdata%/<gamename>/highscores.dat directory without admin persmissions. Windows上,您可以将文件存储在%appdata%/<gamename>/highscores.dat目录中,而无需管理员权限。

  • On Linux you could chose for the directory ~/.<gamename>/highscores.dat Linux上,您可以选择目录~/.<gamename>/highscores.dat

  • On Mac OSX you could chose the directory /Users/<USERNAME>/Library/Application Support/<gamename>/highscores.dat Mac OSX上,您可以选择目录/Users/<USERNAME>/Library/Application Support/<gamename>/highscores.dat

If you do it like this, the file wont be showing up on your games' folder. 如果您这样做,文件将不会显示在游戏的文件夹中。 This has also the advantage of maintaining the highscores data, even when you move your game to another location. 即使将游戏移到另一个位置,这也具有保持高分数据的优势。

可能您可以使用任何加密技术,然后将其写入乐谱文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM