Java ArrayList to Array convertArrayListToHexString(ArrayList al)

Here you can find the source of convertArrayListToHexString(ArrayList al)

Description

convert Array List To Hex String

License

BSD License

Parameter

Parameter Description
ArrayList that needs to be converted to a HEX-Formated String

Return

HEX-formated String

Declaration

public static String convertArrayListToHexString(ArrayList<Byte> al) 

Method Source Code

//package com.java2s;
/**/*from   w w w.j  a va  2  s  . c  o  m*/
 * KMIPUtils.java
 * -----------------------------------------------------------------
 *     __ __ __  ___________ 
 *    / //_//  |/  /  _/ __ \     .--.
 *   / ,<  / /|_/ // // /_/ /    /.-. '----------.
 *  / /| |/ /  / // // ____/     \'-' .--"--""-"-'
 * /_/ |_/_/  /_/___/_/           '--'
 * 
 * -----------------------------------------------------------------
 * Description for class
 * This class is a collection of multiple used functions
 *
 * @author     Stefanie Meile <stefaniemeile@gmail.com>
 * @author     Michael Guster <michael.guster@gmail.com>
 * @org.       NTB - University of Applied Sciences Buchs, (CH)
 * @copyright  Copyright ? 2013, Stefanie Meile, Michael Guster
 * @license    Simplified BSD License (see LICENSE.TXT)
 * @version    1.0, 2013/08/09
 * @since      Class available since Release 1.0
 *
 * 
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    /** 
     * @param ArrayList that needs to be converted to a HEX-Formated String
     * @return HEX-formated String
     */
    public static String convertArrayListToHexString(ArrayList<Byte> al) {
        StringBuffer buf = new StringBuffer();
        for (Byte b : al) {
            buf.append(String.format("%02X", b));
        }
        return buf.toString();
    }

    /** 
     * @param List<Byte> that needs to be converted to a HEX-Formated String
     * @return HEX-formated String
     */
    public static String convertArrayListToHexString(List<Byte> al) {
        StringBuffer buf = new StringBuffer();
        for (Byte b : al) {
            buf.append(String.format("%02X", b));
        }
        return buf.toString();
    }
}

Related

  1. byteArrayListToByteArray(ArrayList indata)
  2. byteArrayListToCharToString(ArrayList byteArrayList)
  3. convertArrayListToIntArray(ArrayList al)
  4. convertIntArrayList2array(ArrayList alInput)
  5. convertStringArrayListToArray(ArrayList al)
  6. doubleArrayList2Array(ArrayList a)