byte[] i1 = "\r\nA\r\nBC\r".getBytes();
byte[] i2 = "\n\r\nDEF\r\n".getBytes();
NewlineFilter nlFilter = NewlineFilter.createWin2Nix(false);
ByteBuffer input = ByteBuffer.allocate(i1.length + i2.length);
ByteBuffer res = ByteBuffer.allocate(i1.length + i2.length); // at most of the original size
nlFilter.preview(ByteBuffer.wrap(i1));
nlFilter.preview(ByteBuffer.wrap(i2));
//
input.put(i1).flip();
res.put(nlFilter.filter(input));
Assert.assertTrue("Unpocessed chars shall be left in input buffer", input.remaining() > 0);