Here you can find the source of byteToHexString(byte[] bytes, int start, int end)
Parameter | Description |
---|---|
bytes | a parameter |
start | start index, inclusively |
end | end index, exclusively |
public static String byteToHexString(byte[] bytes, int start, int end)
//package com.java2s; public class Main { /**//from ww w . ja va 2s . c om * Given an array of bytes it will convert the bytes to a hex string representation of the bytes * * @param bytes * @param start * start index, inclusively * @param end * end index, exclusively * @return hex string representation of the byte array */ public static String byteToHexString(byte[] bytes, int start, int end) { if (bytes == null) { throw new IllegalArgumentException("bytes == null"); } StringBuilder s = new StringBuilder(); for (int i = start; i < end; i++) { s.append(String.format("%02x", bytes[i])); } return s.toString(); } /** Same as byteToHexString(bytes, 0, bytes.length). */ public static String byteToHexString(byte bytes[]) { return byteToHexString(bytes, 0, bytes.length); } public static String toString(String[] content, String sign) { if (null == content) { return null; } sign = null == sign ? "," : sign; StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < content.length; i++) { strBuilder.append(content[i]); if (i < content.length - 1) { strBuilder.append(sign); } } return strBuilder.toString(); } }