Class ByteReader
java.lang.Object
cool.scx.bytes.ByteReader
- All Implemented Interfaces:
IByteReader
ByteReader
- Version:
- 0.0.1
- Author:
- scx567888
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendByteChunk(ByteChunk byteChunk) longensureAvailable(long maxPullCount) longensureAvailableOrThrow(long maxPullCount) longfindIndex(ByteIndexer indexer, long maxLength, long maxPullCount) longindexOf(ByteIndexer indexer, long maxLength, long maxPullCount) 查找索引intInputStream 写法的 readintinputStreamRead(byte[] b, int off, int len) InputStream 写法的 readbyte[]inputStreamReadNBytes(long len) InputStream 写法的 readlonginputStreamTransferTo(OutputStream out, long maxLength) InputStream 写法的 TransferTovoidmark()标记bytepeek()查看单个字节 (指针会移动) 当没有更多的数据时会抛出异常voidpeek(ByteConsumer byteConsumer, long maxLength, long maxPullCount) 向 byteConsumer 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常booleanbyteread()读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常voidread(ByteConsumer byteConsumer, long maxLength, long maxPullCount) 向 byteConsumer 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常voidreset()重置voidwalk(ByteConsumer consumer, long maxLength, boolean movePointer, long maxPullCount)
-
Field Details
-
byteSupplier
-
head
-
tail
-
markNode
-
markNodePosition
public int markNodePosition
-
-
Constructor Details
-
ByteReader
-
ByteReader
public ByteReader()
-
-
Method Details
-
appendByteChunk
-
pullByteChunk
- Throws:
ByteSupplierException
-
ensureAvailable
- Throws:
ByteSupplierException
-
ensureAvailableOrThrow
public long ensureAvailableOrThrow(long maxPullCount) throws NoMoreDataException, ByteSupplierException -
walk
public void walk(ByteConsumer consumer, long maxLength, boolean movePointer, long maxPullCount) throws ByteSupplierException - Throws:
ByteSupplierException
-
findIndex
public long findIndex(ByteIndexer indexer, long maxLength, long maxPullCount) throws NoMatchFoundException, ByteSupplierException -
read
Description copied from interface:IByteReader读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
readin interfaceIByteReader- Returns:
- byte
- Throws:
NoMoreDataException- 没有更多数据时抛出ByteSupplierException
-
read
public void read(ByteConsumer byteConsumer, long maxLength, long maxPullCount) throws NoMoreDataException, ByteSupplierException Description copied from interface:IByteReader向 byteConsumer 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
readin interfaceIByteReader- Parameters:
byteConsumer- 消费者maxLength- 最大长度maxPullCount- 最大长度- Throws:
NoMoreDataException- 没有更多数据时抛出ByteSupplierException
-
peek
Description copied from interface:IByteReader查看单个字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
peekin interfaceIByteReader- Returns:
- byte
- Throws:
NoMoreDataException- 没有更多数据时抛出ByteSupplierException
-
peek
public void peek(ByteConsumer byteConsumer, long maxLength, long maxPullCount) throws NoMoreDataException, ByteSupplierException Description copied from interface:IByteReader向 byteConsumer 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常- Specified by:
peekin interfaceIByteReader- Parameters:
byteConsumer- 消费者maxLength- 最大长度maxPullCount- 最大长度- Throws:
NoMoreDataException- 没有更多数据时抛出ByteSupplierException
-
indexOf
public long indexOf(ByteIndexer indexer, long maxLength, long maxPullCount) throws NoMatchFoundException, NoMoreDataException, ByteSupplierException Description copied from interface:IByteReader查找索引- Specified by:
indexOfin interfaceIByteReader- Throws:
NoMatchFoundExceptionNoMoreDataExceptionByteSupplierException
-
mark
public void mark()Description copied from interface:IByteReader标记- Specified by:
markin interfaceIByteReader
-
reset
public void reset()Description copied from interface:IByteReader重置- Specified by:
resetin interfaceIByteReader
-
inputStreamRead
Description copied from interface:IByteReaderInputStream 写法的 read- Specified by:
inputStreamReadin interfaceIByteReader- Throws:
IOException
-
inputStreamRead
Description copied from interface:IByteReaderInputStream 写法的 read- Specified by:
inputStreamReadin interfaceIByteReader- Throws:
IOException
-
inputStreamTransferTo
Description copied from interface:IByteReaderInputStream 写法的 TransferTo- Specified by:
inputStreamTransferToin interfaceIByteReader- Throws:
IOException
-
inputStreamReadNBytes
Description copied from interface:IByteReaderInputStream 写法的 read- Specified by:
inputStreamReadNBytesin interfaceIByteReader- Throws:
IOException
-