Monday, 25 April 2016

How to open local files using Java program ?


Open local files


java.awt.Desktop myNewBrowserDesktop = 
                      java.awt.Desktop.getDesktop();

try {
  // Open local file
  myNewBrowserDesktop.open(new File("C:\\Documents and 
        Settings\\QLDC1776\\Desktop\\notice.pdf"));
} catch (URISyntaxException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.