Class InputStreamOrByteBufferAdapter
- java.lang.Object
-
- io.github.lukehutch.fastclasspathscanner.utils.InputStreamOrByteBufferAdapter
-
public abstract class InputStreamOrByteBufferAdapter extends Object
Buffer class that can wrap either an InputStream or a ByteBuffer, depending on which is available.
-
-
Constructor Summary
Constructors Constructor Description InputStreamOrByteBufferAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 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)
void
readInitialChunk()
int
readInt()
Read an int from the buffer.int
readInt(int offset)
Read an int from the buffer at a specific offset before the current read point.long
readLong()
Read a long from the buffer.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 offset before the current read point.int
readUnsignedShort()
Read an unsigned short from the buffer.int
readUnsignedShort(int offset)
Read an unsigned short from the buffer at a specific offset before the current read point.void
skip(int bytesToSkip)
Skip the given number of bytes in the input stream.
-
-
-
Method Detail
-
readInitialChunk
public void readInitialChunk() throws IOException
- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException, InterruptedException
Read an unsigned byte from the buffer.- Throws:
IOException
InterruptedException
-
readUnsignedByte
public int readUnsignedByte(int offset)
Read an unsigned byte from the buffer at a specific offset before the current read point.
-
readUnsignedShort
public int readUnsignedShort() throws IOException, InterruptedException
Read an unsigned short from the buffer.- Throws:
IOException
InterruptedException
-
readUnsignedShort
public int readUnsignedShort(int offset)
Read an unsigned short from the buffer at a specific offset before the current read point.
-
readInt
public int readInt() throws IOException, InterruptedException
Read an int from the buffer.- Throws:
IOException
InterruptedException
-
readInt
public int readInt(int offset) throws IOException
Read an int from the buffer at a specific offset before the current read point.- Throws:
IOException
-
readLong
public long readLong() throws IOException, InterruptedException
Read a long from the buffer.- Throws:
IOException
InterruptedException
-
readLong
public long readLong(int offset) throws IOException
Read a long from the buffer at a specific offset before the current read point.- Throws:
IOException
-
skip
public void skip(int bytesToSkip) throws IOException, InterruptedException
Skip the given number of bytes in the input stream.- Throws:
IOException
InterruptedException
-
readString
public 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 ";".
-
read
public abstract int read(byte[] array, int off, int len) throws IOException
- Throws:
IOException
-
create
public static InputStreamOrByteBufferAdapter create(InputStream inputStream) throws IOException
Create a new InputStream adapter.- Throws:
IOException
-
create
public static InputStreamOrByteBufferAdapter create(ByteBuffer byteBuffer) throws IOException
Create a new ByteBuffer adapter.- Throws:
IOException
-
-