您好,在这里我想将字节数组即0x3eb转换为short,所以我认为0x3eb为字符串,并尝试转换为short,但其抛出Numberformat Exception ...有人请帮助我
import java.io.UnsupportedEncodingException;
public class mmmain
{
public static void main(String[] args) throws UnsupportedEncodingException
{
String ss="0x03eb";
Short value = Short.parseShort(ss);
System.out.println("value--->"+value);
}
}
Exception what im getting is
Exception in thread "main" java.lang.NumberFormatException:
For input string: "0x3eb" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:491)
at java.lang.Short.parseShort(Short.java:117)
at java.lang.Short.parseShort(Short.java:143)
at mmmain.main(mmmain.java:14)
即使我尝试将0x3eb转换为字节
byte [] bytes = ss.getBytes();
但是我没有发现解析字节的任何实现。
提前致谢