Consume a and write a pdf from a webservice in Java
<p>Iv been asked to consume a pdf from a webservice in java.The problem is I do not know how to write on to a file so that it can be well seen by pdf viewers.</p>

<pre><code>URL url = new URL("http://localhost:9090/xcvbb/rest/integrationservices/getPDF");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/pdf");

if (conn.getResponseCode() != 200) {
    throw new RuntimeException("Failed : HTTP error code : "
            + conn.getResponseCode());
}

BufferedReader br = new BufferedReader(new InputStreamReader(
                (conn.getInputStream())));

             //writing the downloaded data into the file we created
            FileOutputStream fileOutput = new FileOutputStream("C:/Users/dkimigho/Downloads/bitarraypdf.pdf");

            String output;
            System.out.println("Output from Server2 .... \n");
            while ((output = br.readLine()) != null) {

                fileOutput.write(br.readLine().getBytes());
            }

            //closed the output stream
            fileOutput.close();
            ///
            conn.disconnect();

          } catch (MalformedURLException e) {

            e.printStackTrace();

          } catch (IOException e) {

            e.printStackTrace();

          }
</code></pre>

<p>Any help on this will be highly appreciated.</p>