Java examples for java.awt:Desktop
open pdf File
//package com.java2s; import java.awt.Desktop; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void openFile(String filename, byte[] data) { try {/*from w ww . j a va2 s . co m*/ // Create temp file. File temp = File.createTempFile("sentinel_", ".pdf"); // Delete temp file when program exits. temp.deleteOnExit(); // Write to temp file FileOutputStream fos = new FileOutputStream(temp); fos.write(data); fos.close(); Desktop.getDesktop().open(temp); } catch (IOException e) { e.printStackTrace(); } } }