Here's an easy way to get a String-form md5 sum of binary data. It's easier to use BigInteger to hex-encode the result, as for all practical purposes, Integer.toHexString and related Integer methods are broken, by not using leading zeros. The code is HERE

import java.math.BigInteger;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class MD5 {

    public static void main(String[] args) {
        System.out.println(asString(args[0].getBytes()));
    }

    /**
     * Get a string form md5 digest of a byte array
     *
     * @param data The byte array to be encoded
     *
     * @return The md5-encoded String
     */
    public static String asString(byte[] data) {
        String result = null;

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            result = new BigInteger(1, md.digest(data)).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return result;
    }
}