Here you can find the source of toHex(final byte[] data)
Parameter | Description |
---|---|
data | the data to convert |
public static String toHex(final byte[] data)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006, 2014 TH4 SYSTEMS GmbH and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j av a2s .com*/ * TH4 SYSTEMS GmbH - initial API and implementation * IBH SYSTEMS GmbH - documentation, add toHex *******************************************************************************/ public class Main { /** * Convert byte array to hex string * * @param data * the data to convert * @return a hex string, lower case, no delimiters */ public static String toHex(final byte[] data) { if (data == null) { return null; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.length; i++) { sb.append(String.format("%02x", data[i])); } return sb.toString(); } }