java 请教一个16进制的字符串转成整数返回的函数,谢谢

比如说String s = "1323abcf";
[b]问题补充:[/b]
我想知道自己写一个函数如何实现,谢谢大家

Long.valueOf(s, 16)

public int transfer(String str){
return Integer.valueOf(str,16).intValue();
}

晕,,,去看java源代码啊。。。。

[code="java"] public static long parseLong(String s, int radix)
throws NumberFormatException
{
if (s == null) {
throw new NumberFormatException("null");
}

if (radix < Character.MIN_RADIX) {
    throw new NumberFormatException("radix " + radix +
                    " less than Character.MIN_RADIX");
}
if (radix > Character.MAX_RADIX) {
    throw new NumberFormatException("radix " + radix +
                    " greater than Character.MAX_RADIX");
}

long result = 0;
boolean negative = false;
int i = 0, max = s.length();
long limit;
long multmin;
int digit;

if (max > 0) {
    if (s.charAt(0) == '-') {
    negative = true;
    limit = Long.MIN_VALUE;
    i++;
    } else {
    limit = -Long.MAX_VALUE;
    }
        if (radix == 10) {
            multmin = negative ? MULTMIN_RADIX_TEN : N_MULTMAX_RADIX_TEN;
        } else {
            multmin = limit / radix;
        }
        if (i < max) {
            digit = Character.digit(s.charAt(i++),radix);
    if (digit < 0) {
        throw NumberFormatException.forInputString(s);
    } else {
        result = -digit;
    }
    }
    while (i < max) {
    // Accumulating negatively avoids surprises near MAX_VALUE
    digit = Character.digit(s.charAt(i++),radix);
    if (digit < 0) {
        throw NumberFormatException.forInputString(s);
    }
    if (result < multmin) {
        throw NumberFormatException.forInputString(s);
    }
    result *= radix;
    if (result < limit + digit) {
        throw NumberFormatException.forInputString(s);
    }
    result -= digit;
    }
} else {
    throw NumberFormatException.forInputString(s);
}
if (negative) {
    if (i > 1) {
    return result;
    } else {    /* Only got "-" */
    throw NumberFormatException.forInputString(s);
    }
} else {
    return -result;
}
}[/code]