Here you can find the source of toHexString(byte[] bytes)
Parameter | Description |
---|---|
bytes | the converted bytes |
Parameter | Description |
---|---|
IllegalArgumentException | if the byte array is null |
public static String toHexString(byte[] bytes)
//package com.java2s; /*/*from w ww . java 2s .c om*/ * Copyright (C) 2006-2016 Talend Inc. - www.talend.com * * This source code is available under agreement available at * %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt * * You should have received a copy of the agreement along with this program; if not, write to Talend SA 9 rue Pages * 92150 Suresnes, France */ public class Main { /** * Returns a string in the hexadecimal format. * * @param bytes the converted bytes * @return the hexadecimal string representing the bytes data * @throws IllegalArgumentException if the byte array is null */ public static String toHexString(byte[] bytes) { if (bytes == null) { throw new IllegalArgumentException("byte array must not be null"); //$NON-NLS-1$ } StringBuilder hex = new StringBuilder(bytes.length * 2); for (byte aByte : bytes) { hex.append(Character.forDigit((aByte & 0XF0) >> 4, 16)); hex.append(Character.forDigit((aByte & 0X0F), 16)); } return hex.toString(); } }