title: Get image from http GET response as base64 String
body: <p>When my GET request for an image returns an encoded string like <code>‰PNGØßn¥àí»Øèª¯ÐPÒäœ?Å'Üë²...</code></p>
  
  <p>How can I get the image as a base64 encoded String, instead of whatever encoding this is?</p>
  
  <pre><code>    String url = http://i.stack.imgur.com/tKsDb.png;
  
      try{
  
      URL obj = new URL(url);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  
      // optional default is GET
      con.setRequestMethod("GET");
  
      //add request header
      con.setRequestProperty("User-Agent", "Mozilla/5.0");
  
      int responseCode = con.getResponseCode();
      System.out.println("\nSending 'GET' request to URL : " + url);
      System.out.println("Response Code : " + responseCode);
  
      BufferedReader in = new BufferedReader(
              new InputStreamReader(con.getInputStream()));
      String inputLine;
      StringBuffer response = new StringBuffer();
  
      while ((inputLine = in.readLine()) != null) {
          response.append(inputLine);
      }
      in.close();
      System.out.println(response.toString());
      //print result
      return response.toString();
  </code></pre>