专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > GIS

接收GPS终端数据乱码解决办法

发布时间:2010-06-06 17:10:38 文章来源:www.iduyao.cn 采编人员:星星草
接收GPS终端数据乱码
hhhH?++/ '#
hhhH馃
hhhH?

代码
Java code
public void doService(){
                System.out.println("server doService now!");
                while(server!=null){
                    Socket socket=null;
                    InputStream in=null;
                    OutputStream out=null;
                    try {
                        socket = server.accept();
                        in=getBufferedInputStream(socket);
                        byte[] tmp=new byte[1024];
                        int re=-1;
                        while((re=in.read(tmp))!=-1){
                            System.out.println(new String(tmp,0,re));
                        }
                        out=getBufferedOutputStream(socket);
                        out = getBufferedOutputStream(socket);
                        out.write("i have received your message!".getBytes());
                        out.write(new byte[] { 0x0d, 0x0a });
                        out.flush();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }finally{
                        try{
                            in.close();
                            out.close();
                            socket.close();
                        }catch (Exception e) {
                            // TODO: handle exception
                        }
                        
                    }
                    
                }
            }


------解决方案--------------------
你没转16进制字符串当然乱了
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: