How can i open/view .pdf/.doc files that are save in database? I have this class name FileAttachment:
...
private Object file;
private String fileName;
//getter and setters
and on my Dao Class i called my longblob datatype:
Blob file;
if(rset.getBlob("file")!=null){
file = rset.getBlob("file");
}else{
file = null;
}
attachment.setFile(file);
attachment.setFileName(rset.getString("file_name"));
My concern now is How do i open/view this file on my application?. I tried something like this:
private void lblFileContentMouseClicked(java.awt.event.MouseEvent evt) {
try {
File file = new File(attachment.getFile().toString());
System.out.println("file "+file);
if(file.exists()){
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+file);
p.waitFor();
}else{
System.out.println("File is not found ");
}
...
However, it does not work.
Any help is much appreciated