Strings { public static String formatMD5(byte[] md5, boolean toLowerCase) { BaseEncoding encoder = toLowerCase ? BaseEncoding.base16().lowerCase() : BaseEncoding.base16().upperCase(); return encoder.encode(md5); }  static List<String> entriesToString(Map<?, ?> map); static String nl(); static String join(Collection<?> strings); static String join(Object... strings); static String join(Collection<?> strings, String delimiter); static String repeatString(String str, int count); static List<String> stringAndSort(Collection<?> inputs); static List<String> stringAndSort(Map<?,?> inputs); static List<String> dumpResource(Class<?> forClass, String path); static List<String> dumpURLs(Enumeration<URL> urls); @SuppressWarnings("unused") // primarily useful in debuggers static String[] dumpException(Throwable t); static String toOctal(byte[] bytes); static String hex(byte[] bytes); static String hex(ByteSource byteSource); static String hex(byte[] bytes, int start, int length); static ByteSource parseHexWithout0x(String st); static ByteSource parseHex(String string); static List<String> readStream(InputStream is); static void readStreamTo(InputStream is, Appendable out, boolean keepNL); static String toString(Multimap<T,?> map); static String stripr(String input, String suffix); static List<String> dumpFile(File file); static String dumpFileToString(File file); static List<String> mapToString(Collection<?> collection); static boolean equalCharsets(Charset one, String two); static String formatMD5(byte[] md5, boolean toLowerCase); static String truncateIfNecessary(String str, int codePointCount); static String toBase64(byte[] bytes); static String toBase64(byte[] bytes, int offset, int length); static byte[] fromBase64(CharSequence cs); static String[] parseQualifiedName(String arg, int maxParts); static String quotedIdent(String s, char quote, boolean force); static String escapeIdentifier(String s); static final String NL; }
@Test public void formatMD5() { byte[] md5 = {0x01, 0x39, (byte) 0xef, (byte) 0xc1, (byte) 0xe9, (byte) 0x86, 0x22, 0x33, 0x74, 0x3a, 0x75, 0x77, (byte) 0x98, (byte) 0xdd, (byte) 0x9c}; String expected = "0139efc1e9862233743a757798dd9c"; String actual = Strings.formatMD5(md5, true); assertEquals ("bytes", expected, actual); }