153 |
*/ |
*/ |
154 |
public static byte parseByte(String s, int radix) |
public static byte parseByte(String s, int radix) |
155 |
{ |
{ |
156 |
int i = Integer.parseInt(s, radix); |
int i = Integer.parseInt(s, radix, false); |
157 |
if ((byte) i != i) |
if ((byte) i != i) |
158 |
throw new NumberFormatException(); |
throw new NumberFormatException(); |
159 |
return (byte) i; |
return (byte) i; |
212 |
* <em>DecimalDigit</em>: |
* <em>DecimalDigit</em>: |
213 |
* <em>Character.digit(d, 16) has value 0 to 15</em> |
* <em>Character.digit(d, 16) has value 0 to 15</em> |
214 |
* </pre> |
* </pre> |
215 |
* Note that you cannot decode MIN_VALUE, as the specification requires |
* Finally, the value must be in the range <code>MIN_VALUE</code> to |
216 |
* that the digits be parsed before negating the result, but 128 will not |
* <code>MAX_VALUE</code>, or an exception is thrown. |
|
* fit in a byte. |
|
217 |
* |
* |
218 |
* @param s the <code>String</code> to interpret |
* @param s the <code>String</code> to interpret |
219 |
* @return the value of the String as a <code>Byte</code> |
* @return the value of the String as a <code>Byte</code> |
220 |
* @throws NumberFormatException if <code>s</code> cannot be parsed as a |
* @throws NumberFormatException if <code>s</code> cannot be parsed as a |
221 |
* <code>byte</code> |
* <code>byte</code> |
222 |
* @throws NullPointerException if s is null |
* @throws NullPointerException if <code>s</code> is null |
223 |
* @see Integer#decode(String) |
* @see Integer#decode(String) |
224 |
*/ |
*/ |
225 |
public static Byte decode(String s) |
public static Byte decode(String s) |
226 |
{ |
{ |
227 |
int i = (Integer.decode(str)).intValue(); |
int i = Integer.parseInt(s, 10, true); |
228 |
if ((byte) i != i) |
if ((byte) i != i) |
229 |
throw new NumberFormatException(); |
throw new NumberFormatException(); |
230 |
return new Byte((byte) i); |
return new Byte((byte) i); |