Invoke the default editor to edit a file : Desktop « JDK 6 « Java






Invoke the default editor to edit a file

  

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;

public class Test {
  public static void main(String[] a) {
    try {
      Desktop desktop = null;
      if (Desktop.isDesktopSupported()) {
        desktop = Desktop.getDesktop();
      }

       desktop.edit(new File("c:\\a.txt"));
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }

  }
}

          
  








Related examples in the same category

1.Using the Desktop class to launch a URL with default browser
2.Using the system default setting to open a file
3.Open a office word file with Java
4.Using system default printer to print a file out
5.Send out email
6.Open Mail client
7.Desktop Help Applications
8.This program demonstrates the desktop app API.