Remove unused buffer utils
This commit is contained in:
parent
6a73fa3a8f
commit
0244372efb
@ -8,49 +8,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class BufferUtils {
|
public class BufferUtils {
|
||||||
|
|
||||||
private static final int CHUNK_SIZE = 8192;
|
|
||||||
|
|
||||||
public static void writeBuf(ByteBufOutputStream os, Buffer dataToWrite) throws IOException {
|
|
||||||
var len = dataToWrite.length();
|
|
||||||
os.writeInt(len);
|
|
||||||
byte[] part = new byte[CHUNK_SIZE];
|
|
||||||
for (int i = 0; i < len; i += CHUNK_SIZE) {
|
|
||||||
var end = Math.min(i + CHUNK_SIZE, len);
|
|
||||||
dataToWrite.getBytes(i, end, part, 0);
|
|
||||||
os.write(part, 0, end - i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Buffer readBuf(ByteBufInputStream is) throws IOException {
|
|
||||||
int len = is.readInt();
|
|
||||||
Buffer buf = Buffer.buffer(len);
|
|
||||||
byte[] part = new byte[1024];
|
|
||||||
int readPart = 0;
|
|
||||||
for (int i = 0; i < len; i += 1024) {
|
|
||||||
var lenx = (Math.min(i + 1024, len)) - i;
|
|
||||||
if (lenx > 0) {
|
|
||||||
readPart = is.readNBytes(part, 0, lenx);
|
|
||||||
buf.appendBytes(part, 0, readPart);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static io.vertx.core.buffer.Buffer rxReadBuf(ByteBufInputStream is) throws IOException {
|
|
||||||
int len = is.readInt();
|
|
||||||
io.vertx.core.buffer.Buffer buf = io.vertx.core.buffer.Buffer.buffer(len);
|
|
||||||
byte[] part = new byte[1024];
|
|
||||||
int readPart = 0;
|
|
||||||
for (int i = 0; i < len; i += 1024) {
|
|
||||||
var lenx = (Math.min(i + 1024, len)) - i;
|
|
||||||
if (lenx > 0) {
|
|
||||||
readPart = is.readNBytes(part, 0, lenx);
|
|
||||||
buf.appendBytes(part, 0, readPart);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Writer {
|
public interface Writer {
|
||||||
|
|
||||||
void write(ByteBufOutputStream os) throws IOException;
|
void write(ByteBufOutputStream os) throws IOException;
|
||||||
|
Loading…
Reference in New Issue
Block a user