Skip to content

Commit 00be617

Browse files
committed
API.java allow partial reads
1 parent c432c65 commit 00be617

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

API.class

-204 Bytes
Binary file not shown.

API.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void display(String result) throws Exception
7676

7777
public void process(String cmd, InetAddress ip, int port) throws Exception
7878
{
79+
StringBuffer sb = new StringBuffer();
7980
char buf[] = new char[MAXRECEIVESIZE];
8081
int len = 0;
8182

@@ -89,7 +90,15 @@ public void process(String cmd, InetAddress ip, int port) throws Exception
8990
ps.flush();
9091

9192
InputStreamReader isr = new InputStreamReader(socket.getInputStream());
92-
len = isr.read(buf, 0, MAXRECEIVESIZE);
93+
while (0x80085 > 0)
94+
{
95+
len = isr.read(buf, 0, MAXRECEIVESIZE);
96+
if (len < 1)
97+
break;
98+
sb.append(buf, 0, len);
99+
if (buf[len-1] == '\0')
100+
break;
101+
}
93102

94103
closeAll();
95104
}
@@ -100,7 +109,7 @@ public void process(String cmd, InetAddress ip, int port) throws Exception
100109
return;
101110
}
102111

103-
String result = new String(buf, 0, len);
112+
String result = sb.toString();
104113

105114
System.out.println("Answer='"+result+"'");
106115

0 commit comments

Comments
 (0)