Skip to content

Commit 29eeccd

Browse files
committed
Use readFully method.
1 parent 3609010 commit 29eeccd

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/main/java/com/codebutler/android_websockets/HybiParser.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,17 +362,7 @@ public HappyDataInputStream(InputStream in) {
362362

363363
public byte[] readBytes(int length) throws IOException {
364364
byte[] buffer = new byte[length];
365-
int total = 0;
366-
while (total < length) {
367-
int count = read(buffer, total, length - total);
368-
if (count == -1) {
369-
break;
370-
}
371-
total += count;
372-
}
373-
if (total != length) {
374-
throw new IOException(String.format("Read wrong number of bytes. Got: %s, Expected: %s.", total, length));
375-
}
365+
readFully(buffer);
376366
return buffer;
377367
}
378368
}

0 commit comments

Comments
 (0)