in core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java [163:202]
public int readLine(final ByteArrayBuffer dst) throws IOException {
if (dst == null) {
throw new IllegalArgumentException("Destination buffer may not be null");
}
if (!readAllowed()) return -1;
int total = 0;
boolean found = false;
int bytesRead = 0;
while (!found) {
if (!hasData()) {
bytesRead = fillBuffer();
if (endOfStream() && !hasData()) {
skipBoundary();
verifyEndOfStream();
bytesRead = -1;
break;
}
}
int len = this.limit - this.buffer.pos();
int i = this.buffer.indexOf((byte)'\n', this.buffer.pos(), len);
int chunk;
if (i != -1) {
found = true;
chunk = i + 1 - this.buffer.pos();
} else {
chunk = len;
}
if (chunk > 0) {
dst.append(this.buffer.buf(), this.buffer.pos(), chunk);
this.buffer.skip(chunk);
total += chunk;
}
}
if (total == 0 && bytesRead == -1) {
return -1;
} else {
return total;
}
}