Created
October 2, 2018 03:20
-
-
Save kpradeep12/4804bbcde77e55ab91ed3fb90445cc4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DesktopUtility { | |
public static void main(String[] args) throws URISyntaxException, IOException { | |
Desktop desktop = java.awt.Desktop.getDesktop(); | |
if(!Desktop.isDesktopSupported()) | |
return; | |
// Opens composing window of default mail client | |
desktop.mail(new URI("mailto:<email address>")); | |
// Launches default browser | |
desktop.browse(new URI("http://techstackjava.com/")); | |
// Opens a folder containing the file | |
desktop.browseFileDirectory(new File("/opt")); | |
// Opens a file in associate application | |
desktop.open(new File("/opt/users.txt")); | |
// Prints a file with native desktop printing facility | |
desktop.print(new File("/opt/report.txt")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment