Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Commit fd805dd

Browse files
committed
Flush when a newline character is written
1 parent 5817d1a commit fd805dd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/de/kaleidox/vban/VBAN.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public VBAN<D> sendData(D data) throws IOException, IllegalArgumentException {
6666
/**
6767
* Writes one byte to this stream's byte buffer, but does not send anything.
6868
* The byte buffer is being sent and cleared by invoking {@link #flush()}.
69+
* If the character-code of {@code \n} is written, the stream is flushed,
70+
* to ensure a 1:1 ratio of lines:writes.
6971
*
7072
* @param b The byte as an int to append.
7173
* @throws IOException If the stream has been {@linkplain #close() closed} before.
@@ -76,6 +78,7 @@ public void write(int b) throws IOException {
7678
if (buf.length + 1 > MAX_SIZE)
7779
throw new IOException("Byte array is too large, must be smaller than " + MAX_SIZE);
7880
buf = appendByteArray(buf, (byte) b);
81+
if ((char) b == '\n') flush();
7982
}
8083

8184
/**

0 commit comments

Comments
 (0)