Java Byte Convert From bytesFromHexString(String values)

Here you can find the source of bytesFromHexString(String values)

Description

bytes From Hex String

License

Open Source License

Declaration

static byte[] bytesFromHexString(String values) 

Method Source Code

//package com.java2s;
/*//from  w  w w . jav a2  s  .c  om
 * Copyright (c) 2014 ConteXtream Systems, Inc. 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
 */

public class Main {
    static byte[] bytesFromHexString(String values) {
        String target = "";
        if (values != null) {
            target = values;
        }
        String[] octets = target.split(":");

        byte[] ret = new byte[octets.length];
        for (int i = 0; i < octets.length; i++) {
            ret[i] = Integer.valueOf(octets[i], 16).byteValue();
        }
        return ret;
    }
}

Related

  1. asByte(Object o)
  2. booleanAsByte(boolean val)
  3. bytesFrom(String hwAddress)
  4. bytesFromDpid(long dpid)
  5. bytesFromHex(String s)
  6. bytesFromLong(long l)
  7. bytesFromString(String bytes)
  8. bytesFromString(String string)