public static String encodeBase64(String input){
  return DatatypeConverter.printBase64Binary(input.getBytes(StandardCharsets.UTF_8));
}

public static String encodeBase64 ( String input ) { return DatatypeConverter . printBase64Binary ( input . getBytes ( StandardCharsets . UTF_8 ) ) ; }
creates a base 64 encoded string from the given input string .
