// Example Foo.xls will be opened with Excel
// Make sure to import the class java.awt.Desktop
public static void OpenFile(String filename){
try{
// Check if class 'Desktop' is supported on the platform
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(new File(filename));
}else{
System.out.println("Class Desktop is unsupported");
}
} catch (Exception ex){
System.out.println("Error opening "+ filename);
}
}
No comments:
Post a Comment