Monday 3 June 2019

Java: Get path to System desktop


Below statement returns the path to system desktop.
System.getProperty("user.home") + File.separator + "Desktop";

App.java
package com.sample.app;

import java.io.File;

public class App {

 public static void main(String args[]) {

  String desktopPath = System.getProperty("user.home") + File.separator + "Desktop";
  System.out.print(desktopPath);

 }
}


You may like

No comments:

Post a Comment