Java Swing Tutorial - Java Desktop.edit(File file)








Syntax

Desktop.edit(File file) has the following syntax.

public void edit(File file)  throws IOException

Example

In the following code shows how to use Desktop.edit(File file) method.

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
/*  w w  w.j  a  va2 s .co  m*/
public class Main {
  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();
    }

  }
}