首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

从ByteBuffer中获取基本门类

2012-12-18 
从ByteBuffer中获取基本类型我们可以从ByteBuffer中产生出不同类型值的方法public class Test{public stat

从ByteBuffer中获取基本类型
我们可以从ByteBuffer中产生出不同类型值的方法
 

public class Test{       public static final int BSIZE=1024;       public static void main(){            ByteBuffer bb=ByteBuffer.allocate(BSIZE);            int i=0;            while(i++<bb.limit())       if(bb.get()!=0)                   System.out.print("nozero");               System.out.println("i ="+i);               bb.rewind();               bb.asShortBuffer().put((short)471142);               System.out.print(bb.getShort());               bb.rewind();               bb.asIntBuffer().put(9947142);               System.out.print(bb.getInt());               bb.rewind();               bb.asLongBuffer().put(99471142);               System.out.print(bb.getLong());               bb.rewind();               bb.asFloatBuffer().put(99471142);               System.out.print(bb.getFloat());               bb.rewind();               bb.asDoubleBuffer().put(99471142);               System.out.print(bb.getDouble());               bb.rewind();                                              }}

热点排行