0

A game that I am writing in java will require some files to be written locally for anyone that downloads the game, this is for high scores, images, achievements, etc...

Current code:

File file = new File("C:\\Directory\\File.txt"); 

But what I need (since I'm not going to be the only one using this) is to find the directory in which the user will download the game and operate the game, thus I can write the necessary files (on launch) to their local directory (in order to access and write to).

Seamus
  • 4,539
  • 2
  • 32
  • 42

1 Answers1

0

Instead of:

File file = new File("C:\\Directory\\File.txt");

If you do:

File file = new File("File.txt");

You won't need to know what the path is. This will create the file in the same directory as the app.

Seamus
  • 4,539
  • 2
  • 32
  • 42