Get bytearray from pdf URL in java
Below code converts pdf from URL to byteArray
It need common-httpClient.jar from apache HttpComponents .
Download link – http://hc.apache.org/downloads.cgi
String url= "http://gradcollege.okstate.edu/sites/default/files/PDF_linking.pdf"; byte[] byteArray = null; HttpClient httpClient =null; { try { httpClient =new httpClient(); httpGetmethod =new GetMethod(url); httpGetmethod.setFollowRedirects(true); byteArray = httpGetmethod.getResponseBody(); } catch (Exception ex) { System.out.println("Error Logs "+ex); } finally() { if(httpGetmethod !=null) { httpGetmethod.releaseConnection(); } } System.out.println("ByeArray Generated"+new XStream().toXML(byteArray)); }