Package tv.hd3g.transfertfiles
Class BufferVault
java.lang.Object
tv.hd3g.transfertfiles.BufferVault
Thread safe
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidcompactAndAppend(int pos, BufferVault inserted) Remove all internal datas betwen 0 and pos, add append (copy/write) newDataSource content.copy()ensureBufferSize(int itemsCountToAdd) booleanintgetSize()inthashCode()Iterator<byte[]>iterator(int bufferSize) Internal buffer will be reused for each nextintread(byte[] b, int pos, int off, int len) intread(int pos) read(OutputStream outStream) Don't close/flush after write.byte[]readAll()Stream<byte[]>stream(int bufferSize) Internal buffer will be reused for each itemstatic BufferVaultwrap(byte[] byteArrayToHeapByteBuffer) Short end for ByteBuffer.wrap and BufferVault.wrap(ByteBuffer)write(byte[] buffer) write(byte[] buffer, int pos, int len) intwrite(InputStream inStream, int bufferSize) Don't close/flush after read, call available before start read to pre-heat internal bufferwrite(ByteBuffer buffer)
-
Constructor Details
-
BufferVault
public BufferVault() -
BufferVault
public BufferVault(int baseInternalArraySize)
-
-
Method Details
-
copy
-
wrap
Short end for ByteBuffer.wrap and BufferVault.wrap(ByteBuffer)- Parameters:
byteArrayToHeaByteBuffer-- Returns:
-
ensureBufferSize
-
clear
public void clear() -
write
- Returns:
- this
-
write
- Returns:
- this
-
write
- Returns:
- this
-
getSize
public int getSize() -
readAll
public byte[] readAll()- Returns:
- empty if not datas to read.
-
read
public int read(byte[] b, int pos, int off, int len) - Parameters:
b- the array to feed with dataspos- where start to read data in internal arrayoff- where to put data in blen- max data len to put in b- Returns:
- real data len readed from internal array, -1 no datas/pos to big
-
read
public int read(int pos) -
readAllToByteBuffer
- Returns:
- empty if not datas to read.
-
iterator
Internal buffer will be reused for each next -
stream
Internal buffer will be reused for each item -
asOutputStream
-
read
Don't close/flush after write. Inject direcly the internal byte array. If outStream change it, it will change internally.- Returns:
- this
- Throws:
IOException
-
write
Don't close/flush after read, call available before start read to pre-heat internal buffer- Parameters:
inStream-- Returns:
- total transferred bytes
- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
compactAndAppend
Remove all internal datas betwen 0 and pos, add append (copy/write) newDataSource content.
-