首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

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

2012-08-27 
接收GPS终端数据乱码hhhH?++/ #hhhH馃hhhH?代码Java codepublic void doService(){

接收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进制字符串当然乱了

热点排行