Convert BufferedReader to File
<p>I have a servlet which returns a PDF document to the requesting user. When it is called from a browser, the PDF document is automatically downloaded.
Now I need to call this servlet from Java (standalone code, not server side). Once this Java code gets the PDF document, it needs to convert it to images using Apache PDF Box API.</p>

<p>This is how my Java code looks like. It writes bytes to the screen.</p>

<pre><code>URL url = new URL("http://localhost:8080/Stream/Document&amp;type=pdf");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); 
String line = in.readLine();
System.out.println( line ); 
in.close();
</code></pre>

<p>and this is how the code to convert it to Images looks like</p>

<pre><code>String pdfFileName = "myfile.pdf";
PDDocument document = PDDocument.load(new File(pdfFileName)); 
</code></pre>

<p>Now I need to combine these two so that the PDF file that is downloaded (in memory, would prefer not to write it to Filesystem) is converted to JPG. So, instead of passing a hardcoded filename, I somehow need to convert the BufferedReader object to File object and pass it as an input to PDDocument.</p>

<p>I am not able to make out how this conversion would happen. </p>