これはうまくいくはずです:
File b64 = new File("loop.png.b64");
FileInputStream fis = new FileInputStream(b64);
byte[] bytes = IOUtils.toByteArray(fis);
byte[] decoded = Base64.decodeBase64(bytes);
ImageIcon img = new ImageIcon(decoded);
if (img.getIconWidth() > -1 && img.getIconHeight() > -1) {
System.out.println("OK");
}
それloop.png.b64
は次のとおりです。
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBI
WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AgBFxQTkp15LgAAAbNJREFUOMutUz1LIwEUnDhh/ai2
VIOyTRoRtVERAm4iWggKV9kGrbTI+lGIlfgL1vwC8RdsZSVi5HJypwleciGHrJL1W2y0iai4PCvD
mg8Vcdo3M8x7zAO+AzcLCz02KYek5EnJkZIh5a+q3r5yDgYGrOzUlF7T5Hx83Cw3+D80tAYA+enp
nt+k7JKyPzJienV17yVTgsF1APD5/Xd1LS0OADxsbc3+GR42364Qi+nlK+Ta2gpeTs4w1LSur/0k
JUFKKhrVSwmeMhkDABgIOA2jo6sA0NDbu+416IzH75Surjk2NzsA8JjPG6XhMSk2KZeTk1EAsEMh
y5mf16qtlZ6YiCZI2SYFAPzeoa+pyQGAYDL5A8lk1bu8cj51xM/gjYHc32sfCapyzgcHLZuUo/b2
wuXSklpL/C8WU3cDgUKClF99fVYpgdLdHQcA9+JCe0ilzLPFxQqTnGGoT9ms6V5fawBQ39ERBwCf
t4nFjY1ZF4CvtdVRwuEVaWx0XBE8F4tacWdn+fnqSnMBKJHIav/m5lxFxJOxMdNb5QNS0qTskVKr
yhU4nZnR7VDIKjf48Jm+ihfxk8RykW8L+wAAAABJRU5ErkJggg==