Base64 { public static String encode(byte[] data) { if (encoderMethod == null) throw new UnsupportedOperationException("Cannot find Base64 encoder."); try { return (String) encoderMethod.invoke(encoderObject, data); } catch (Exception e) { throw new UnsupportedOperationException(e); } } private  Base64(); static byte[] decode(String data); static String encode(byte[] data);  }
@Test public void testEncode() { String input = "Hello World!"; String result = Base64.encode(input.getBytes()); assertEquals("SGVsbG8gV29ybGQh", result); }