Base64Utils { public static byte[] decode(final String base64Encoded) { try { if (null == base64Encoded || base64Encoded.isEmpty()) { return new byte[0]; } return BaseEncoding.base64().decode(base64Encoded); } catch (Exception e) { throw new IllegalArgumentException(e); } }  static String encode(final byte[] raw); static byte[] decode(final String base64Encoded);  }
@Test public void testDecode() throws IOException { assertTrue(Arrays.equals(DECODED, Base64Utils.decode(ENCODED))); assertTrue(Arrays.equals(new byte[0], Base64Utils.decode(""))); assertTrue(Arrays.equals(new byte[0], Base64Utils.decode(null))); }