import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
byte a[] ;
byte k[]=new byte[2*4];
float b[] = new float[2];
float c[] = new float[2];
for(int i=0;i<2;i++){
b[i]=i+1010;
}
ByteBuffer bb = ByteBuffer.wrap(k);
FloatBuffer fBuffer = bb.asFloatBuffer();
fBuffer.put(b);
FloatBuffer fb1 = bb.asFloatBuffer();
fb1.get(c);
System.out.println("c1="+c[0]);
System.out.println("c2="+c[1]);
}
}
|