Languages
[Edit]
EN

Java - find temporary directory path

11 points
Created by:
illona
526

In this short article, we would like to show how to find path to temporary directory where we can store temporary files using Java.

Quick solution:

 

Practical example

Edit

By default, operating systems have a place to store temporary files needed by many applications.

Motivation to use that store may be special features like:

  • protection against access across different users,
  • supported fast IO operations (e.g. virtual file systems in memory or dedicated fast storage),
  • cleaning when the operating system is turned off.

Note: in Java we can change default temporary directory path by running: java -Djava.io.tmpdir=/path/to/temporary-directory

Example program:

Example output (under Windows):

Where: john is directory used by currently logged-in user account.

 

Alternative titles

  1. Java - get temporary directory path
  2. Java - get java.io.tmpdir path
  3. Java - find tmp directory path
  4. Java - find temp directory path
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join