//粘包解决方法,格式<x>XXXXXXXXXXXX</x>
?? ??? ?public void readMess(String message){
?????????? //存放数据
?? ??? ??? ?data = data+message;
?? ??? ??? ?try{
???????? //循环是数据可能有多个<x>XXX</x><x>XXX</x>.................
?? ??? ??? ? while((data.indexOf("<x>")>-1) && (data.indexOf("</x>")>-1))
?? ??? ??? ? {
?? ??? ??? ??? ?int n1 = data.indexOf("<x>");
?? ??? ??? ??? ?int n2 = data.indexOf("</x>");
?? ??? ??? ??? ?String str = data.substring(n1+3, n2);
?? ??? ??? ??? ?//剩余字符
?? ??? ??? ??? ?data = data.substring(n2+4);
?? ??? ???????? //打印处理好的字符
?? ??? ??? ??? ?Log.v("readM", str);
?? ??? ??? ? }
?? ??? ??? ?}
?? ??? ??? ?catch(Exception e)
?? ??? ??? ?{
?? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ?}
?? ??? ?}