读书人

hbase的bytes跟String 转换

发布时间: 2013-03-06 16:20:31 作者: rapoo

hbase的bytes和String 转换

ByteBuffer byteBuffer = ByteBuffer.allocate(8);

byteBuffer.putInt(1234);

? ? ? ? byteBuffer.putInt(5678);

? ? ? ? byte[] rowkey = byteBuffer.array();?

? ? ? ? for (byte b: rowkey){

? ? ? ? System.out.println(b);

? ? ? ? }

? ? ? ? String sb = Bytes.toStringBinary(rowkey);

? ? ? ? String s = rowkey.toString();

? ? ? ? rowkey = s.getBytes();

? ? ? ? for (byte b: rowkey){

? ? ? ? System.out.println(b);

? ? ? ? }

? ? ? ? System.out.println(sb);

? ? ? ??

? ? ? ? rowkey = "test".getBytes();

? ? ? ? System.out.println(Bytes.toString(rowkey));

? ? ? ? System.out.println(Bytes.toStringBinary(rowkey)); ??

读书人网 >开源软件

热点推荐