I have a signed applet that extracts a PDF from a web service, then saves it in the temp folder and opens it in Adobe Reader. I would like to avoid storing the file locally, but I really don't know how to achieve it (I'm new to Java applets).
If it was a web application (i.e. a simple servlet), I could just write the PDF content by ServletResponse; then the browser will save it in its temporary folder and open it using Adobe Reader (or any other application associated with the MIME type).
Is there a similar way to do this ... on a Java applet?
This is my code:
public class MyListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
byte[] content = webService.getPdfDocument(...);
File f = new File("my-document-filename.pdf");
FileOutputStream fos = new FileOutputStream(f);
fos.write(content);
fos.close();
Desktop.getDesktop().open(new File("my-document-filename.pdf"));
}
}
Any alternative to Desktop.open (File) allowing me to pass in byte[]instead File?