Example usage for java.lang Byte valueOf

List of usage examples for java.lang Byte valueOf

Introduction

In this page you can find the example usage for java.lang Byte valueOf.

Prototype

public static Byte valueOf(String s, int radix) throws NumberFormatException 

Source Link

Document

Returns a Byte object holding the value extracted from the specified String when parsed with the radix given by the second argument.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println("parse string to byte:" + Byte.valueOf("10", 8));
}

From source file:Main.java

public static byte[] addressToBytes(String address) {
    if (address == null || address.length() != STR_ADDRESS_LENGTH) {
        return null;
    }/*from   w  w  w.  j a  va  2  s .  co  m*/

    byte[] result = new byte[ADDRESS_LENGTH];

    for (int i = 0; i < ADDRESS_LENGTH; ++i) {
        result[i] = Byte.valueOf(address.substring(3 * i, 3 * i + 2), 16);
    }

    return result;
}