Java XML String Transform toHexString(byte[] array)

Here you can find the source of toHexString(byte[] array)

Description

Returns a hexadecimal string from a given byte array.

License

Open Source License

Parameter

Parameter Description
array The byte array which is to transformed into a hexadecimal string

Return

The hexadecimal string

Declaration

public static String toHexString(byte[] array) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2016 Dr.-Ing. Marc M?ltin.
 *  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  a  v a 2 s.  c o  m
 *    Dr.-Ing. Marc M?ltin - initial API and implementation and initial documentation
 *******************************************************************************/

import javax.xml.bind.DatatypeConverter;

public class Main {
    /**
     * Returns a hexadecimal string from a given byte array.
     * 
     * @param  array The byte array which is to transformed into a hexadecimal string
     * @return The hexadecimal string
     */
    public static String toHexString(byte[] array) {
        if (array != null)
            return DatatypeConverter.printHexBinary(array);
        else
            return "";
    }
}

Related

  1. String2Doc(String InputXMLString)
  2. string2Source(String xml)
  3. stringToNode(String s)
  4. strToSchema(final String strXsd)
  5. toElement(String xml)
  6. toHTML(String xml)
  7. toJson(String xml)
  8. toLCCNDisplay(String packedLCCN)
  9. tomcatPort(String fileName)