Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

How to use mkdir in java without knowing full path

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Manhattanisgr8   Members   

487
Like
0Likes
Like

Posted 05 August 2014 - 01:43 AM

I am currently making a text based game using swing. I plan on using a wrapper to distribute the program. The question I have is; How do I make a new directory without knowing where the user installed the game? Basically I want to have something like this:

 

GameFolder\Data\(This is where I would want to make the new directory with the name the end user specifies)

 

Any help or direction would greatly be appreciated.


Cpl Alt, Travis A

USMC


#2 BitMaster   Members   

8647
Like
3Likes
Like

Posted 05 August 2014 - 01:54 AM

If the user installed the game it was most likely installed in the local equivalent of "Program Files", at least on Windows. You should not try to write there at all. If you need to store data, querying System.getProperty("user.home") would probably be the way to go.

If there is no conventional installation and/or you want the application to be portable you might want to query System.getProperty("user.dir") instead. However, my last adventure in Java has been a while so I'm not sure if there are better ways. I faintly remember having asked the root ClassLoader of the application of a similar question once but you would have to check with the documentation for details or whether that really makes sense.

#3 rip-off   Moderators   

10896
Like
2Likes
Like

Posted 05 August 2014 - 04:51 AM

Searching for Java user files directory, the third result I got looks especially promising.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.