• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Open a PDF fie inside a jar

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I would like to know how can I open a PDF that is inside the jar file, programatically. My first idea was:

In the code above, I receive an InputStream but I dont know what to do with this, I would to open the PDF file or to copy the PDF file for a directory known by the user and then open with:


Thanks in advance!
 
Rancher
Posts: 43045
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's code that reads from an InputStream and writes to an OutputStream: http://www.exampledepot.com/egs/java.io/CopyFile.html
It should be easy to adapt that to your situation.
 
Sheriff
Posts: 22715
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a temporary file to write to:
 
Alberto Ivo
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob, thanks for the answer...

but this won't help me... See, I want to open an existing pdf file inside the JAR, not to create one temporary file... I think I didn't explain my problem properly.

I want to copy an existing PDF file inside a jar file to a known directory and then open this file.

thanks..
 
Rob Spoor
Sheriff
Posts: 22715
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I missed that you were going to use a known directory to store the PDF. Because that much is certain - you have to extract it first. If you don't have a known directory then my temp file solution is a good alternative.
 
Alberto Ivo
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm.. ok then..

but how can I extract the pdf File from the and copy it to a known directory. I already have the InputStream of the file:
 
Ulf Dittmer
Rancher
Posts: 43045
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't that pretty much what the code examples I linked to does - copying from an InputStream to a file?
 
Alberto Ivo
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.. Ulf, Thanks very much!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic