Decodes a
String
into a
Byte
. Accepts decimal, hexadecimal, and octal numbers given by the following grammar:
-
DecodableString:
-
Signopt DecimalNumeral
-
Signopt
0x
HexDigits
-
Signopt
0X
HexDigits
-
Signopt
#
HexDigits
-
Signopt
0
OctalDigits
-
Sign:
-
-
-
+
DecimalNumeral,
HexDigits, and
OctalDigits are as defined in section
3.10.1 of
The Java Language Specification , except that underscores are not accepted between digits.
The sequence of characters following an optional sign and/or radix specifier ("0x
", "0X
", "#
", or leading zero) is parsed as by the Byte.parseByte
method with the indicated radix (10, 16, or 8). This sequence of characters must represent a positive value or a NumberFormatException
will be thrown. The result is negated if first character of the specified String
is the minus sign. No whitespace characters are permitted in the String
.
valueOf(byte)
is generally a better choice, as it is likely to yield significantly better space and time performance.