title: How do I display an image on the browser using Java?
body: <p>I have a web service which returns a <code>BufferedImage</code> value, but I am unable to display the image in my browser, knowing that I have already converted it from <code>byte[]</code> to <code>BufferedImage</code>.</p>
  
  <p>I receive a result like following.</p>
  
  <p>This is how I convert the <code>byte[]</code> data (I can see the data in <code>byte[]</code>):</p>
  
  <pre><code>ResponseEntity&lt;byte[]&gt; result =  new RestTemplate(messageConverters).exchange(new URI(url), HttpMethod.GET, httpEntity,  byte[].class );
  try {
      BufferedImage img = ImageIO.read(new ByteArrayInputStream(result.getBody()));
      return img;
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>And I get something like this:</p>
  
  <pre><code>{  
     "accelerationPriority":0.5,
     "colorModel":{  
        "transparency":3,
        "numComponents":4,
        "numColorComponents":3,
        "colorSpace":{  
           "type":5,
           "numComponents":3,
           "profile":{  
              "mediaWhitePoint":[  
                 0.9504547,
                 1.0,
                 1.0890503
              ],
              "matrix":[  
                 [  
                    0.43606567,
                    0.3851471,
                    0.1430664
                 ],
                 [  
                    0.2224884,
                    0.71687317,
                    0.06060791
                 ],
                 [  
                    0.013916016,
                    0.097076416,
                    0.71409607
                 ]
              ],
              "data":"AAAMSGxjbXMCEAAAbW50clJHQiBYWVogB84AAgAJAAYAMQAAYWNzcE1TRlQAAAAASUVDIHNSR0IAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1sY21zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARY3BydAAAAVAAAAAzZGVzYwAAAYQAAABsd3RwdAAAAfAAAAAUYmtwdAAAAgQAAAAUclhZWgAAAhgAAAAUZ1hZWgAAAiwAAAAUYlhZWgAAAkAAAAAUZG1uZAAAAlQAAABwZG1kZAAAAsQAAACIdnVlZAAAA0wAAACGdmlldwAAA9Q...
  </code></pre>