Skip to content

Commit 8306f1b

Browse files
mint-runsmint-runs
authored andcommitted
update ReadingByteBuffer.java
1 parent e84bbed commit 8306f1b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/de/javasocketapi/core/ReadingByteBuffer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.nio.ByteBuffer;
55
import java.nio.charset.StandardCharsets;
66
import java.util.UUID;
7+
import java.util.stream.IntStream;
78

89
public class ReadingByteBuffer {
910
private final ByteBuffer byteBuffer;
@@ -57,9 +58,7 @@ public String readString() {
5758
//read string
5859
final int length = this.readInt();
5960
final byte[] bytes = new byte[length];
60-
for (int i = 0; i < length; i++) {
61-
bytes[i] = this.readByte();
62-
}
61+
IntStream.range(0, length).forEach(i -> bytes[i] = this.readByte());
6362
return new String(bytes, StandardCharsets.UTF_8);
6463
}
6564

0 commit comments

Comments
 (0)