Tuesday, June 14, 2011

OpenPDFUsingJava

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

/**
*
* @author R.Amirtharaj
*/
public class OpenPDFUsingJava {

public static void main(String[] args) {

try {

File pdfFile = new File("C:"+File.separator+"MyFile.pdf");
if (pdfFile.exists()) {

if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(pdfFile);
} else {
System.out.println("Awt Desktop is not supported!");
}

} else {
System.out.println("File is not exists!");
}

System.out.println("Done");

} catch (Exception ex) {
ex.printStackTrace();
}

}


}

No comments:

Post a Comment