多字节数据类型数组(double,float,int,long)数组数组和byte数组的相互转换都可以基于java.nio.Buffer实现....java.nio.DoubleBuffer对应double[],
java.nio.FloatBuffer对应float[],
java.nio.LongBuffer对应long[],
java.nio.IntBuffer...对应int[]
…
byte[] 转 double[],float[],int[]…
byte[]转double[],float[],int[]…很简单因为ByteBuffer本身就有asDoubleBuffer...[] res = new float[buffer.remaining()];
buffer.get(res);
return res;
}
public static int[] asIntArray...[],int[]…转byte[]
反过来,从多字节类型数组(double[],float[],long[]…)转byte[]要稍麻烦一些,因为多字节类型数组对应的Buffer类并没提供asByteBuffer