- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Operating System temporary directory / folder in Java
To get the temporary directory in Java, use the System.getProperty() method. Use the
It’s syntax is −
String getProperty(String key)
Above, the key is the name of the system property. Since, we want the Java Home Directory name, therefore we will add the key as −
java.io.tmpdir
The following is an example −
Example
public class Demo { public static void main(String []args){ String strTmp = System.getProperty("java.io.tmpdir"); System.out.println("OS current temporary directory: " + strTmp); System.out.println("OS Name: " + System.getProperty("os.name")); System.out.println("OS Version: " + System.getProperty("os.version")); } }
Output
OS current temporary directory: /tmp OS Name: Linux OS Version: 3.10.0-862.9.1.el7.x86_64
- Related Articles
- Create temporary file in specified directory in Java
- Java Program to get Operating System name and version
- How to create a directory in project folder using Java?
- Display the Operating System name in Java
- Get Java Home Directory
- How to get system data directory information in android?
- Get the Current Working Directory in Java
- File system Implementation in Operating System
- Difference Between Network Operating System and Distributed Operating System
- Semaphores in Operating System
- Buffering in Operating System
- Concurrency in Operating System
- Kernel in Operating System
- Livelock in Operating System
- Create Directory or Folder with C/C++ Program

Advertisements