Desktop path for file output Java
File desktop = new File(System.getProperty("user.home"), "Desktop");
Get absolute desktop path
If you want to get the result of the method getCurrentUserDesktopPath()
in your Mover class, you just need to put this line in your main method:
String desktopPath = WindowsUtils.getCurrentUserDesktopPath();
As this method is made static you don't need to declare a WindowsUtils
object.
Get desktop path with groovy
To get your desktop path in Groovy you can use your Java code directly, since it works perfectly:
String userHomeFolder = System.getProperty("user.home") + "/Desktop";
If you want an alternative a Groovy way to do so could be:
String userHomeFolder = System.properties['user.home'] + "/Desktop"
Or:
String userHomeFolder = System.properties.'user.home' + "/Desktop"
All of this gets the same result.
In java under Windows, how do I find a redirected Desktop folder?
FileSystemView filesys = FileSystemView.getFileSystemView();
filesys.getHomeDirectory()
Related Topics
Prevent SQL Injection Attacks in a Java Program
What Is the Class Object (Java.Lang.Class)
Spring MVC - How to Return Simple String as JSON in Rest Controller
How to Use Jsch for Ssh Key-Based Communication
How to Import Spring-Config.Xml of One Project into Spring-Config.Xml of Another Project
Spring Autowiring Using @Configurable
Delete Item from Array and Shrink Array
How to Insert Image into Jtable Cell
Pass String as Params from One Java App to Another
Static VS. Dynamic Binding in Java
How to Call Some Blocking Method with a Timeout in Java
Java: How to Import a Jar File from Command Line
Streaming Large Result Sets with MySQL
How to Convert Current Date into String in Java