Properties of the system
Improving the response to the message! collected all the information and gathered it together.
public static void main(String[] args) { String myDirectory = "Yash"; // user Folder Name String path = getUsersHomeDir() + File.separator + myDirectory ; if (new File(path).mkdir()) { System.out.println("Directory is created!"); }else{ System.out.println("Failed to create directory!"); } getOSInfo(); } public static void getOSInfo(){ String os = System.getProperty("os.name"); String osbitVersion = System.getProperty("os.arch"); String jvmbitVersion = System.getProperty("sun.arch.data.model"); System.out.println(os + " : "+osbitVersion+" : "+jvmbitVersion); } public static String getUsersHomeDir() { String users_home = System.getProperty("user.home"); return users_home.replace("\\", "/"); // to support all platforms. }
To print all available properties.
for (Entry<Object, Object> e : System.getProperties().entrySet()) { System.out.println(String.format("%s = %s", e.getKey(), e.getValue())); }
source share