Example usage for java.awt Desktop edit

List of usage examples for java.awt Desktop edit

Introduction

In this page you can find the example usage for java.awt Desktop edit.

Prototype

public void edit(File file) throws IOException 

Source Link

Document

Launches the associated editor application and opens a file for editing.

Usage

From source file:Main.java

public static void main(String[] a) {
    try {/*  w w  w.  j  av a2 s  .c  om*/
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }

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

}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private void editNameSourceFile() throws IOException, InterruptedException {
    try {/* w w w.jav  a  2  s  . c o m*/
        Desktop desktop = Desktop.getDesktop();
        desktop.edit(new File("config/namesources.tsv"));
    } catch (Exception e) {
        //Fallback
        final Process p = Runtime.getRuntime().exec("gedit config/namesources.tsv");
        if (p.waitFor() != 0) {
            final Process q = Runtime.getRuntime().exec("edit config/namesources.tsv");
        }

        //   (new Thread() {         
        //            @Override
        //            public void run()
        //            {
        //               try {
        //                  // normal termination
        //                  int returnCode = p.waitFor();
        //                  System.out.println(returnCode);
        //                  if(returnCode==0)
        //                  {
        //                     System.out.println("terminated!!");
        //                     frame.reloadNamesources();
        //                     frame.startLabelThread();
        //                  }
        //               } catch (InterruptedException e) {}            
        //            }
        //         }).start();
    }
}

From source file:npm.modules.java

public boolean openafile(String path) throws Exception {
    File file = new File(path);
    Desktop desktop = Desktop.getDesktop();
    desktop.edit(file);
    return true;//from  ww w .  ja v  a 2s. co  m
}