Class IconExe.LEDataInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.eclipse.pde.internal.swt.tools.IconExe.LEDataInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Enclosing class:
- IconExe
static class IconExe.LEDataInputStream extends java.io.InputStream
-
-
Constructor Summary
Constructors Constructor Description LEDataInputStream(java.io.InputStream input)LEDataInputStream(java.io.InputStream input, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Answers how many bytes are available for reading without blockingvoidclose()intgetPosition()Answer 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.shortreadShort()Answer a short comprised of the next two bytes of the input stream.voidunread(byte[] b)Push back the entire content of the given bufferb.
-
-
-
Field Detail
-
position
int position
-
in
java.io.InputStream in
-
buf
protected byte[] buf
The byte array containing the bytes to read.
-
pos
protected int pos
The 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.
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
getPosition
public int getPosition()
Answer how many bytes were read.
-
available
public int available() throws java.io.IOExceptionAnswers how many bytes are available for reading without blocking- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOExceptionAnswer the next byte of the input stream.- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionDon't imitate the JDK behaviour of reading a random number of bytes when you can actually read them all.- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
readData
private int readData(byte[] buffer, int offset, int length) throws java.io.IOExceptionReads 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:
java.io.IOException- if an IOException occurs.
-
readInt
public int readInt() throws java.io.IOExceptionAnswer an integer comprised of the next four bytes of the input stream.- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOExceptionAnswer a short comprised of the next two bytes of the input stream.- Throws:
java.io.IOException
-
unread
public void unread(byte[] b) throws java.io.IOExceptionPush 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:
java.io.IOException- if the pushback buffer is too small
-
-