美文网首页
使用socket接收数据为空

使用socket接收数据为空

作者: efd3a6f0145f | 来源:发表于2018-09-11 11:01 被阅读0次

    String result ="";

    try {

    inputStream =socket.getInputStream();

    DataInputStream input =new DataInputStream(inputStream);

    int count =0;

    while (count ==0) {

    count = input.available();

    }

    byte[] b =new byte[count];

    int len = input.read(b);

    result =new String(b,0, len);

    parseString(result);//解析得到的字符串

    }catch (Exception e) {

    e.printStackTrace();

    }finally {

    disConnSocket();//断开连接

    }

    相关文章

      网友评论

          本文标题:使用socket接收数据为空

          本文链接:https://www.haomeiwen.com/subject/zjgygftx.html