27 lines
594 B
Java
27 lines
594 B
Java
package com.comphenix.protocol.utility;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.nio.ByteBuffer;
|
|
|
|
/**
|
|
* Represents an output stream that is backed by a ByteBuffer.
|
|
* @author Kristian
|
|
*/
|
|
public class ByteBufferOutputStream extends OutputStream {
|
|
ByteBuffer buf;
|
|
|
|
public ByteBufferOutputStream(ByteBuffer buf) {
|
|
this.buf = buf;
|
|
}
|
|
|
|
public void write(int b) throws IOException {
|
|
buf.put((byte) b);
|
|
}
|
|
|
|
public void write(byte[] bytes, int off, int len)
|
|
throws IOException {
|
|
buf.put(bytes, off, len);
|
|
}
|
|
}
|