142. Working with temporary files/folders

The Java NIO.2 API provides support for working with temporary folders/files. For example, we can easily locate the default location for temporary folders/files as follows:

String defaultBaseDir = System.getProperty("java.io.tmpdir");

Commonly, in Windows, the default temporary folder is C:Temp, %Windows%Temp, or a temporary directory per user in Local SettingsTemp (this location is usually controlled via the TEMP environment variable). In Linux/Unix, the global temporary directories are /tmp and /var/tmp. The preceding line of code will return the default location, depending on the operating system.

In the next section, we'll learn how to create a temporary folder/file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset