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

android接收字节流成乱码,该怎么处理

2013-07-04 
android接收字节流成乱码public static final String bmGBKSocket socketchar[] buffernew char[100

android接收字节流成乱码
public static final String bm="GBK";
Socket socket;
char[] buffer=new char[100];
 BufferedReader in= new BufferedReader(new InputStreamReader(socket.getInputStream(),bm));
 String  act="";
 char str=(char) in.read(buffer);
act=new String(buffer).trim();
 mTextView.setText(act);
求解啊!我收到的16进制的数据为中文乱码!我要接收的数据是0x04 0x7f 0x11 0x6a Android 乱码
[解决办法]
new String时候指定编码试试
[解决办法]
str = new String(bytes,"utf-8");
缓冲区换成byte数组试试,然后转码

热点排行