How to get base64 encoded contents for an ImageReader?

Posted by htf on Stack Overflow See other posts from Stack Overflow or by htf
Published on 2010-06-18T09:33:17Z Indexed on 2010/06/18 11:13 UTC
Read the original article Hit count: 480

Filed under:
|
|

Hi. How do I read an image into a base64 encoded string by its ImageReader?

Here's example source code using HtmlUnit. I want to get the base64 String of img:

  WebClient wc = new WebClient();
  wc.setThrowExceptionOnFailingStatusCode(false);
  wc.setThrowExceptionOnScriptError(false);
  HtmlPage p = wc.getPage("http://flickr.com");
  HtmlImage img = (HtmlImage) p.getByXPath("//img").get(3);
  System.out.println(img.getImageReader().getFormatName());

© Stack Overflow or respective owner

Related posts about java

Related posts about image