Here you can find the source of encode(byte[] buf)
public static String encode(byte[] buf)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.Iterator; import java.util.List; public class Main { /**//from w w w .j a va 2s .c o m * Converts specifed byte-array to hex-string. */ public static String encode(byte[] buf) { StringBuffer result = new StringBuffer(2 * buf.length); for (int i = 0; i < buf.length; i++) { int byteAsInt = buf[i] & 0xFF; if (byteAsInt < 16) { result.append("0"); } result.append(Integer.toString(byteAsInt, 16).toLowerCase()); } return result.toString(); } /** * Returns specified files as a string list. Returns never null. */ public static String toString(List<File> files, boolean shortName) { if (files == null) { return "[null]"; } StringBuilder result = new StringBuilder(256); for (Iterator<File> iterator = files.iterator(); iterator.hasNext();) { File file = iterator.next(); if (result.length() > 0) { result.append(", "); } String filename = shortName ? file.getName() : file.getAbsolutePath(); result.append(filename); } return result.toString(); } }