Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

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

Prototype

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

Source Link

Document

Returns an Integer 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 byte[] toByte(String hexString) {
    int len = hexString.length() / 2;
    byte[] result = new byte[len];
    for (int i = 0; i < len; i++)
        result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
    return result;
}

From source file:Main.java

private static byte[] toByte(String hexString) {
    // TODO Auto-generated method stub
    int len = hexString.length() / 2;
    byte[] result = new byte[len];
    for (int i = 0; i < len; i++)
        result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
    return result;
}