How do I get user home directory path?

Category: java.lang, viewed: 1748 time(s).
 
package org.kodejava.example.java.lang;
 
public class UserHomeExample 
{
    public static void main(String[] args)
    {
        // This is the key that we used to obtain user home directory
        // in the operating system
        String userHome = "user.home";        
        
        // We get the path by getting the system property with the 
        // defined key above.
        String path = System.getProperty(userHome);
        
        // We print your home path here
        System.out.println("Your Home Path: " + path);
    }
}
 
 

On my machine it print something like:

Your Home Path: C:\Documents and Settings\Kodejava
Bookmark this example!  

Most Viewed Examples

Google

100 Top & Latest


eXTReMe Tracker
visitor stats