In that case you will want to use the PipedOutputStream linked to a PipedInputStream. Once you pass the PipedOutputStream instance into the method which takes the OutputStream as an argument, assuming the
getPdfFile(String, OutputStream) method is constructed such that it uses a separate
Thread to write to the OutputStream, you can then return the PipedInputStream and the user of your method can read from the returned InputStream just as they would any other. If on the other hand the getPdfFile method doesn't write from a separate thread, then you will have to wrap the call to that method in a separate thread created by you, at which point you would have to do a little more exception handling and thread cleanup. Examples of such can be found along with the PipedIn/OutputStream examples through Google.