Class LEDataInputStream
java.lang.Object
java.io.InputStream
org.eclipse.swt.internal.image.LEDataInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]The byte array containing the bytes to read.(package private) InputStreamprotected intThe current position within the byte arraybuf.(package private) int -
Constructor Summary
ConstructorsConstructorDescriptionLEDataInputStream(InputStream input) LEDataInputStream(InputStream input, int bufferSize) -
Method Summary
Modifier and TypeMethodDescriptionintAnswers how many bytes are available for reading without blockingvoidclose()intAnswer how many bytes were read.intread()Answer the next byte of the input stream.intread(byte[] b, int off, int len) Don't imitate the JDK behaviour of reading a random number of bytes when you can actually read them all.private intreadData(byte[] buffer, int offset, int length) Reads at mostlengthbytes from this LEDataInputStream and stores them in byte arraybufferstarting atoffset.intreadInt()Answer an integer comprised of the next four bytes of the input stream.shortAnswer a short comprised of the next two bytes of the input stream.voidunread(byte[] b) Push back the entire content of the given bufferb.Methods inherited from class InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
position
int position -
in
InputStream in -
buf
protected byte[] bufThe byte array containing the bytes to read. -
pos
protected int posThe current position within the byte arraybuf. A value equal to buf.length indicates no bytes available. A value of 0 indicates the buffer is full.
-
-
Constructor Details
-
LEDataInputStream
-
LEDataInputStream
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getPosition
public int getPosition()Answer how many bytes were read. -
available
Answers how many bytes are available for reading without blocking- Overrides:
availablein classInputStream- Throws:
IOException
-
read
Answer the next byte of the input stream.- Specified by:
readin classInputStream- Throws:
IOException
-
read
Don't imitate the JDK behaviour of reading a random number of bytes when you can actually read them all.- Overrides:
readin classInputStream- Throws:
IOException
-
readData
Reads at mostlengthbytes from this LEDataInputStream and stores them in byte arraybufferstarting atoffset.Answer the number of bytes actually read or -1 if no bytes were read and end of stream was encountered. This implementation reads bytes from the pushback buffer first, then the target stream if more bytes are required to satisfy
count.- Parameters:
buffer- the byte array in which to store the read bytes.offset- the offset inbufferto store the read bytes.length- the maximum number of bytes to store inbuffer.- Returns:
- int the number of bytes actually read or -1 if end of stream.
- Throws:
IOException- if an IOException occurs.
-
readInt
Answer an integer comprised of the next four bytes of the input stream.- Throws:
IOException
-
readShort
Answer a short comprised of the next two bytes of the input stream.- Throws:
IOException
-
unread
Push back the entire content of the given bufferb.The bytes are pushed so that they would be read back b[0], b[1], etc. If the push back buffer cannot handle the bytes copied from
b, an IOException will be thrown and no byte will be pushed back.- Parameters:
b- the byte array containing bytes to push back into the stream- Throws:
IOException- if the pushback buffer is too small
-