Sin5k4
Sin5k4

Reputation: 1626

Finding the path of the current user

I'm trying to open a file from Java in Ubuntu using FileInputStream.Now my problem is,how can i find the path of the current user as /home/"currentuser"/myfile.xxx?? Normally i use the path as a string since i know the current user. Regards.

Upvotes: 0

Views: 79

Answers (1)

andih
andih

Reputation: 5603

The user's home directory can be retrieved via

String userHomeDir = System.getProperty("user.home");

See System Properties

Upvotes: 4

Related Questions