From fbf38130d7dc7a93d53c63a9282c7c7ba72b85cc Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Wed, 8 Mar 2017 22:09:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSocket=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BookFloatingServer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/BookFloatingServer.java b/BookFloatingServer.java index 75bca96..1390d6f 100644 --- a/BookFloatingServer.java +++ b/BookFloatingServer.java @@ -26,13 +26,17 @@ class Handle implements Runnable pw=new PrintWriter(os); while(true) - { - String str=br.readLine(); - if(str==null) - { + { + byte[] buf = new byte[1024]; + int len =is.read(buf); + if(len < 0){ break; } + String str = new String(buf,0,len); + + System.out.println("String is: "+str); + Gson gson=new Gson(); AppJsonData data=null; try @@ -41,6 +45,7 @@ class Handle implements Runnable } catch(Exception e) { + e.printStackTrace(); System.out.println("Receive a incorrect json string."); continue; } @@ -57,6 +62,7 @@ class Handle implements Runnable } catch(Exception e) { + e.printStackTrace(); System.out.println("Incorrect Register Data"); break; } @@ -76,6 +82,7 @@ class Handle implements Runnable } catch(Exception e) { + e.printStackTrace(); System.out.println("Incorrect Login Data"); break; }