make readByteArray not block indefinitely
This commit is contained in:
parent
2f47747045
commit
dead98e510
1 changed files with 1 additions and 1 deletions
|
@ -119,7 +119,7 @@ public class TypedInputStream {
|
||||||
public byte[] readByteArray() throws IOException {
|
public byte[] readByteArray() throws IOException {
|
||||||
byte[] bytes = new byte[readInt()];
|
byte[] bytes = new byte[readInt()];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while ((n += stream.read(bytes, n, bytes.length - n)) != 0);
|
while (n != (n += stream.read(bytes, n, bytes.length - n)));
|
||||||
if(n != bytes.length) {
|
if(n != bytes.length) {
|
||||||
byte[] cutBytes = new byte[n];
|
byte[] cutBytes = new byte[n];
|
||||||
System.arraycopy(bytes, 0, cutBytes, 0, n);
|
System.arraycopy(bytes, 0, cutBytes, 0, n);
|
||||||
|
|
Loading…
Add table
Reference in a new issue