package org.kodejava.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:\Users\wsaryada
Or
Your Home Path: /Users/wsaryada
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023