public abstract class InputStreamOrByteBufferAdapter extends Object
Modifier and Type | Field | Description |
---|---|---|
byte[] |
buf |
Bytes read from the beginning of the classfile.
|
int |
curr |
The current position in the buffer.
|
int |
used |
Bytes used in the buffer.
|
Constructor | Description |
---|---|
InputStreamOrByteBufferAdapter() |
Modifier and Type | Method | Description |
---|---|---|
static InputStreamOrByteBufferAdapter |
create(InputStream inputStream) |
Create a new InputStream adapter.
|
static InputStreamOrByteBufferAdapter |
create(ByteBuffer byteBuffer) |
Create a new ByteBuffer adapter.
|
abstract int |
read(byte[] array,
int off,
int len) |
Copy up to len bytes into the byte array, starting at the given offset.
|
void |
readInitialChunk() |
Read an initial chunk of the file into the buffer.
|
int |
readInt() |
|
int |
readInt(int offset) |
Read an int from the buffer at a specific absolute offset before the current read point.
|
long |
readLong() |
|
long |
readLong(int offset) |
Read a long from the buffer at a specific offset before the current read point.
|
String |
readString(int strStart,
boolean replaceSlashWithDot,
boolean stripLSemicolon) |
Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and
optionally removing the prefix "L" and the suffix ";".
|
int |
readUnsignedByte() |
Read an unsigned byte from the buffer.
|
int |
readUnsignedByte(int offset) |
Read an unsigned byte from the buffer at a specific absolute offset before the current read point.
|
int |
readUnsignedShort() |
|
int |
readUnsignedShort(int offset) |
Read an unsigned short from the buffer at a specific absolute offset before the current read point.
|
void |
skip(int bytesToSkip) |
Skip the given number of bytes in the input stream.
|
public byte[] buf
public int curr
public int used
public void readInitialChunk() throws IOException
IOException
- If a chunk of the file content could not be read.public int readUnsignedByte() throws IOException
IOException
- If there was an exception while reading.public int readUnsignedByte(int offset)
offset
- The buffer offset to read from.public int readUnsignedShort() throws IOException
IOException
- If there was an exception while reading.public int readUnsignedShort(int offset)
offset
- The buffer offset to read from.public int readInt() throws IOException
IOException
- If there was an exception while reading.public int readInt(int offset)
offset
- The buffer offset to read from.public long readLong() throws IOException
IOException
- If there was an exception while reading.public long readLong(int offset)
offset
- The buffer offset to read from.public void skip(int bytesToSkip) throws IOException
bytesToSkip
- The number of bytes to skip.IOException
- If there was an exception while reading.public String readString(int strStart, boolean replaceSlashWithDot, boolean stripLSemicolon)
strStart
- The start index of the string.replaceSlashWithDot
- If true, replace '/' with '.'.stripLSemicolon
- If true, string final ';' character.public abstract int read(byte[] array, int off, int len) throws IOException
array
- The array to copy intooff
- The start index for the copy.len
- The maximum number of bytes to copy.IOException
- If the file content could not be read.public static InputStreamOrByteBufferAdapter create(InputStream inputStream)
inputStream
- The InputStream
to use.InputStreamOrByteBufferAdapter
.public static InputStreamOrByteBufferAdapter create(ByteBuffer byteBuffer)
byteBuffer
- The ByteBuffer
to use.InputStreamOrByteBufferAdapter
.Copyright © 2018. All rights reserved.