Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/main/java/org/xerial/snappy/SnappyOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,27 @@ public SnappyOutputStream(OutputStream out, int blockSize, BufferAllocatorFactor
* @see java.io.OutputStream#write(byte[], int, int)
*/
@Override
public void write(byte[] b, int off, int len)
public void write(byte[] b, int byteOffset, int byteLength)
throws IOException
{
rawWrite(b, off, len);
if (closed) {
throw new IOException("Stream is closed");
}
int cursor = 0;
while (cursor < byteLength) {
int readLen = Math.min(byteLength - cursor, blockSize - inputCursor);
// copy the input data to uncompressed buffer
if (readLen > 0) {
System.arraycopy(b, byteOffset + cursor, inputBuffer, inputCursor, readLen);
inputCursor += readLen;
}
if (inputCursor < blockSize) {
return;
}

compressInput();
cursor += readLen;
}
}

/**
Expand Down