Invoke the default editor to edit a file in Java
Description
The following code shows how to invoke the default editor to edit a file.
Example
//from www .ja va2 s. c o m
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] a) throws Exception{
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.edit(new File("c:\\a.txt"));
}
}
The code above generates the following result.