title: I converted BufferedImage to Base64 but How I convert it to Image again?
body: <p>I converted <code>BufferedImage</code>to Base64 format.</p>
  
  <p>How do I now convert this Base64 string to Image again? </p>
  
  <p>I always get an error: <code>image == null</code></p>
  
  <pre><code>try {
      BufferedImage bimg;
      Robot bot;
      bot = new Robot();
      bimg = bot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
      ImageIO.write(bimg, "PNG", new File("C:\\Users\\****\\Desktop\\client.png"));
      /// encode
      String imageString;
      try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
          ImageIO.write(bimg, "PNG", bos);
          byte[] imageBytes = bos.toByteArray();
          imageString = Base64.getEncoder().encodeToString(imageBytes);
      }
      System.out.println("Base64 -" + imageString);
      /// decode
      String decoded = new String(Base64.getDecoder().decode(imageString));
      // System.out.println(decoded);
      byte[] imageByte2 = decoded.getBytes();
      ImageIO.write(ImageIO.read(new ByteArrayInputStream(imageByte2)), "PNG", new File("C:\\Users\\***\\Desktop\\decoded.png"));
  } catch (AWTException | HeadlessException | IOException e) {
      JOptionPane.showMessageDialog(null, e);
  }
  </code></pre>