Java XML Hex toByteArray(String hexDumpString)

Here you can find the source of toByteArray(String hexDumpString)

Description

Converts a hex string to byte array

License

Open Source License

Parameter

Parameter Description
hexDumpString a parameter

Declaration

static public byte[] toByteArray(String hexDumpString) 

Method Source Code

//package com.java2s;
/**/*  w w w . j  a v a  2s.  c om*/
 * Copyright (c) 2010-2015, openHAB.org 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
 */

import javax.xml.bind.DatatypeConverter;

public class Main {
    /**
     * Converts a hex string to byte array
     * @param hexDumpString
     * @return
     */
    static public byte[] toByteArray(String hexDumpString) {
        return DatatypeConverter.parseHexBinary(hexDumpString.replaceAll(
                " ", ""));
    }
}

Related

  1. sha1Hex(final String text)
  2. sha1Hex(String data)
  3. sha1Hex(String message)
  4. stringToHex(String str)
  5. toByteArray(String hex)
  6. toByteArrayFromHexString(String s)
  7. toByteFromHexString(String hexString)
  8. toHex(byte[] bytes)
  9. toHex(byte[] bytes)