遍历Text字符

来源:互联网 发布:锁扣地板 知乎 编辑:程序博客网 时间:2024/05/01 02:23
package ncdc;


import java.nio.ByteBuffer;


import org.apache.hadoop.io.Text;


public class TestIterator {
public static void main(String[] args){
Text t = new Text("\u0041\u00DF\u6771\uD801\uDC00");

ByteBuffer buf = ByteBuffer.wrap(t.getBytes(),0,t.getLength());
int cp;
while(buf.hasRemaining() && (cp = Text.bytesToCodePoint(buf))!=-1){
System.out.println(Integer.toHexString(cp));
}
}
}
0 0
原创粉丝点击