title: Java - GIF to base64 string
body: <p>how to convert gif to base64?</p>
  
  <p>here's what i try so far</p>
  
  <pre><code>public static String convertImageToBase64(String urlString, String type ){
  
      String imageString = null;
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
  
      try {
          URL url = new URL(urlString);
          BufferedImage img = ImageIO.read( url );
  
          ImageIO.write(img, type, bos);
          byte[] imageBytes = bos.toByteArray();
  
          BASE64Encoder encoder = new BASE64Encoder();
          imageString = encoder.encode(imageBytes);
  
          bos.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return imageString;
  }
  </code></pre>
  
  <p>code above is working, but it lost the animation</p>