How do I print a file using the default registered application?

The example code below show you how to print a file using the default registered application’s print command for the corresponding file type. To do the printing we call the Desktop.print(File file) method.

Running the program on Windows operating system will open for instance a notepad.exe and print the data.txt file.

How do I edit a file using the default registered application?

For editing a file using the default registered or associated application we can do a call to the Desktop.edit(File file) method. On the code below we will edit a PNG file, this call will execute registered program such as the Windows Paint or GIMP on Linux operating system.

How do I open a file using the default registered application?

If you want to open a file using the default registered or associated application for those files you can use the Desktop.open(File file) method call. In the example below we’ll ask the Desktop class to open a text file.