
- Java Programming Examples
- Example - Home
- Example - Environment
- Example - Strings
- Example - Arrays
- Example - Date & Time
- Example - Methods
- Example - Files
- Example - Directories
- Example - Exceptions
- Example - Data Structure
- Example - Collections
- Example - Networking
- Example - Threading
- Example - Applets
- Example - Simple GUI
- Example - JDBC
- Example - Regular Exp
- Example - Apache PDF Box
- Example - Apache POI PPT
- Example - Apache POI Excel
- Example - Apache POI Word
- Example - OpenCV
- Example - Apache Tika
- Example - iText
- Java Tutorial
- Java - Tutorial
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find current working directory in Java
Problem Description
How to find current working directory?
Solution
Following example shows how to get current directory using getProperty() method.
public class Main { public static void main(String[] args) { String curDir = System.getProperty("user.dir"); System.out.println("You currently working in :" + curDir+ ": Directory"); } }
Result
The above code sample will produce the following result.
You currently working in :C:\Documents and Settings\user\ My Documents\NetBeansProjects\TestApp: Directory
java_directories.htm
Advertisements