【发布时间】:2014-11-02 09:54:17
【问题描述】:
我需要将一个字节数组转换为双精度。我正在使用
double dvalue = ByteBuffer.wrap(value).getDouble();
但在运行时我得到 BufferUnderflowException 异常
Exception in thread "main" java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Buffer.java:498)
at java.nio.HeapByteBuffer.getDouble(HeapByteBuffer.java:508)
at Myclass.main(Myclass.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
我需要在这里更改什么?
【问题讨论】:
-
你能告诉我们价值声明吗?用一些代码。
标签: java exception double bytearray bytebuffer