List of utility methods to do File Read via ByteBuffer
byte[] | readFullyAndClose(InputStream input) read Fully And Close ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]); while (true) { if (result.remaining() == 0) { result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2)); int actuallyRead = input.read(result.array(), result.position(), result.remaining()); if (actuallyRead == -1) { break; ... |
byte[] | readHeaderArea(InputStream in) read Header Area int input = 0; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteBuffer last4Chars = ByteBuffer.wrap(new byte[4]); while ((input = in.read()) != -1) { byte inputByte = (byte) input; buffer.write(inputByte); last4Chars.put(inputByte); if (emptyLine(last4Chars)) { ... |
ByteBuffer | readInputStream(InputStream input) read Input Stream byte[] buf = new byte[BUFFER_SIZE]; int idx = 0; for (;;) { int rd = input.read(buf, idx, buf.length - idx); if (rd < 0) break; idx += rd; if (idx == buf.length) { ... |
String | readInputStreamToString(InputStream inputStream) read Input Stream To String return readInputStreamToString(inputStream, "UTF-8"); |
int | readInt(byte[] bytes, int index) read Int ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
return byteBuffer.getInt(index);
|
int | readInt(byte[] bytes, int offset, java.nio.ByteOrder byteorder) read Int return java.nio.ByteBuffer.wrap(bytes, offset, 4).order(byteorder).getInt();
|
int | readInt(byte[] in) read Int return ByteBuffer.wrap(in).getInt();
|
int | readInt(ByteArrayInputStream bin) Reads the next 4 bytes from the stream as integer. byte[] buffer = new byte[4]; bin.read(buffer); return ByteBuffer.wrap(buffer).getInt(); |
int | readInt(InputStream in, ByteOrder order) read Int ByteBuffer buf = ByteBuffer.allocate(4);
buf.order(order);
readFully(in, buf);
return buf.getInt();
|
int | readInt(InputStream input) read Int byte[] szBytes = new byte[4]; int read = input.read(szBytes); if (read <= 0) { return 0; return ByteBuffer.wrap(szBytes).getInt(); |