数据转换

sca_shen 2003-08-11 07:02:18
请问各位老大:如何进行char和byte类型的转换
...全文
14 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
老土豆T 2003-08-11
  • 打赏
  • 举报
回复
在sun.io的包java中 有下面两个函数转化函数。
public static ByteToCharConverter getDefault();
public static ByteToCharConverter getConverter(String encoding);


比如
byte bt[] = {(byte)'\u00c4',(byte)'\u00e3'};
ByteToCharConverter converter = ByteToCharConverter.getConverter();
char ch[] = converter.convertAll(bt);
for (int i = 0; i < ch.length; i++) {
System.out.println(Integer.toHexString(ch[i]));
}

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧