Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get path to special system directories using Java

How to extract the path "c:/documents and settings/user" using Java... Is there any method??

like image 291
i2ijeya Avatar asked Nov 21 '25 02:11

i2ijeya


1 Answers

System.getProperty("user.home")

should be enough. See here for an example.

public class UserHomeExample 
{
    public static void main(String[] args)
    {

        System.out.println("User Home Path: "+ System.getProperty("user.home"));
    }
}

Gives:

C:\convert\rajesh\completed>javac UserHomeExample.java

C:\convert\rajesh\completed>java UserHomeExample
User Home Path: C:\Documents and Settings\Administrator
like image 199
VonC Avatar answered Nov 22 '25 16:11

VonC