Reputation: 131
I'm writing a Java program that has to create a folder on the disk, store some file in it, and when the program is terminated, the folder is deleted:
The problem is that, when my program is opened on a random pc, how should it know where to store files?
I saw a lot of installers that already suggest you a path (like "Program Files", "Roaming" etc), how can I make my program know these paths? Thanks.
Upvotes: 1
Views: 35
Reputation: 15622
The standard path is
System.getProperty("java.io.tmpdir");
See: https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties()
you might use it together with
File.createTempFile();
as suggested in this answer: https://stackoverflow.com/a/617438/7023245
Upvotes: 3