user2758902
user2758902

Reputation: 61

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. However, when I play the .exe file and it records the score, the highscores.dat appears in whatever directory the .exe is located. I'm not very familiar with files processing in java aside from creating and reading them using the basic input streams and output streams. 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?

Upvotes: 1

Views: 223

Answers (2)

Stein Dekker
Stein Dekker

Reputation: 803

  • On Windows you could store your file in the %appdata%/<gamename>/highscores.dat directory without admin persmissions.

  • On Linux you could chose for the directory ~/.<gamename>/highscores.dat

  • On Mac OSX you could chose the directory /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.

Upvotes: 2

shikjohari
shikjohari

Reputation: 2288

May be you can go with any encryption technique and then write it on the score file.

Upvotes: 0

Related Questions