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 String formatFileName(String type, long recordId, long size, String ext) {
    String c = "-";
    String dot = ".";
    return type + c + recordId + c + Integer.valueOf(String.valueOf(size), 16) + dot + ext;
}

From source file:Main.java

public static int hexToTen(String paramString) {
    if ((paramString == null) || ((paramString != null) && ("".equals(paramString)))) {
        return 0;
    }// w ww .ja  va  2  s.  c om
    return Integer.valueOf(paramString, 16).intValue();
}

From source file:Main.java

public static int binaryToTen(String paramString) {
    if ((paramString == null) || ((paramString != null) && ("".equals(paramString)))) {
        return 0;
    }/*  w ww  .j  a  v a 2  s  .  co  m*/
    return Integer.valueOf(paramString, 2).intValue();
}

From source file:Main.java

private 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

public static byte[] stringToBytes(String in) {

    int length = in.length() / 2;

    byte[] b = new byte[length];

    for (int i = 0; i < length; i++) {
        b[i] = Integer.valueOf(in.substring(i * 2, i * 2 + 2), 16).byteValue();
    }//from   w  ww.ja  v a2 s.c o m

    return b;
}

From source file:Main.java

public static byte[] toByte(String paramString) {
    int j = paramString.length() / 2;
    byte[] arrayOfByte = new byte[j];
    int i = 0;/*from  w  w  w .j a  v  a  2  s .c  om*/
    while (i < j) {
        arrayOfByte[i] = Integer.valueOf(paramString.substring(i * 2, i * 2 + 2), 16).byteValue();
        i += 1;
    }
    return arrayOfByte;
}

From source file:Main.java

public static int getDataLength(byte byte1, byte byte2) {
    int len16 = 0;
    String hex = Integer.toHexString(byte1 & 0xFF);
    if (hex.length() == 1) {
        hex = '0' + hex;
    }/*from   w w w  .  j  a v a2s .c  o m*/
    len16 = Integer.valueOf(hex, 16);
    int len17 = 0;
    String hex1 = Integer.toHexString(byte2 & 0xFF);
    if (hex1.length() == 1) {
        hex1 = '0' + hex1;
    }
    len17 = Integer.valueOf(hex1, 16);
    int pktLen = len16 * 256 + len17;
    return pktLen;
}

From source file:Main.java

public static byte[] hextoBytes(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

@Deprecated
public static byte[] parseHexString(String str) {
    str = str.trim();/*from   w ww. j av  a 2 s  .  co m*/
    String[] temps = str.split(" ");
    byte[] ret = new byte[temps.length];
    int i = 0;
    for (String t : temps) {
        ret[i] = Integer.valueOf(t, 16).byteValue();
        i++;
    }
    return ret;
}

From source file:Main.java

private 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();
    }/*  w ww  .  ja  v  a  2  s .co  m*/
    return result;
}