当前位置: 代码迷 >> Android >> android接收字节流成乱码解决办法
  详细解决方案

android接收字节流成乱码解决办法

热度:67   发布时间:2016-04-28 05:19:58.0
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
------解决方案--------------------
new String时候指定编码试试
------解决方案--------------------
str = new String(bytes,"utf-8");
缓冲区换成byte数组试试,然后转码
  相关解决方案