From: Ahmed A. <asa...@ya...> - 2010-09-17 06:35:50
|
Hi Brett, It was deprecated, as the byte array can be retrieved from the InputStream by using something like org.apache.commons.io.IOUtils.toByteArray(). Yours, Ahmed ---- Blog: http://asashour.blogspot.com ________________________________ From: Brett Koetsier <bre...@gm...> To: htm...@li... Sent: Fri, September 17, 2010 5:46:55 AM Subject: [Htmlunit-user] WebResponse getContentAsBytes() deprecation Just wondering if there is any practical reason behind this. I currently use this function to download directly accessed images in the following manner (or similar): byte[] imageBytes = ((Page) this.webClient.getPage("path/to/ image")).getWebResponse().getContentAsBytes(); And then write the image to disk. OutputStream out = new FileOutputStream("/path/to/local/file"); out.write(imageBytes); out.close(); Working with an input stream (getContentAsInputStream()) or string (getContentAsString()) and converting back to a byte[] seems inefficient when I can access the byte[] directly. Not a huge deal but it'd be nice to have the byte[] directly available. Is there an alternate/better method for downloading images? Thanks, - Brett K. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |