code: public static Writable encodeHex(final byte[] data) {
          return new Writable() {
              public Writer writeTo(Writer out) throws IOException {
                  for (int i = 0; i < data.length; i++) {
                      // convert byte into unsigned hex string
                      String hexString = Integer.toHexString(data[i] & 0xFF);
  
                      // add leading zero if the length of the string is one
                      if (hexString.length() < 2) {
                          out.write("0");
                      }
  
                      // write hex string to writer
                      out.write(hexString);
                  }
                  return out;
              }
  
              public String toString() {
                  StringWriter buffer = new StringWriter();
  
                  try {
                      writeTo(buffer);
                  } catch (IOException e) {
                      throw new StringWriterIOException(e);
                  }
  
                  return buffer.toString();
              }
          };
      }
docs: Produces a Writable that writes the hex encoding of the byte[]. Calling
  toString() on this Writable returns the hex encoding as a String. The hex
  encoding includes two characters for each byte and all letters are lower case.
  
  @param data byte array to be encoded
  @return object which will write the hex encoding of the byte array
  @see Integer#toHexString(int)