Class ByteBufferInput
java.lang.Object
uk.ac.starlink.fits.ByteBufferInput
- All Implemented Interfaces:
BasicInput
Random-access BasicInput implementation based on a ByteBuffer.
- Since:
- 1 Dec 2014
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases resources belonging to this object.longReturns the curent position in this stream (optional operation).booleanisRandom()Indicates whether this object supports random access.bytereadByte()Reads a byte from the stream.voidreadBytes(byte[] bbuf) Reads bytes into an array from the stream.doubleReads an 8-byte floating point value from the stream.floatReads a 4-byte floating point value from the stream.intreadInt()Reads a 4-byte integer from the stream.longreadLong()Reads an 8-byte integer from the stream.shortReads a 2-byte integer from the stream.voidseek(long pos) Moves the current position of this stream to a given byte offset (optional operation).voidskip(long nbyte) Skips a given number of bytes forwards through the stream.
-
Constructor Details
-
ByteBufferInput
-
-
Method Details
-
isRandom
public boolean isRandom()Description copied from interface:BasicInputIndicates whether this object supports random access. The seek and getOffset methods may only be called if this method returns true.- Specified by:
isRandomin interfaceBasicInput- Returns:
- true iff random access is supported
-
seek
Description copied from interface:BasicInputMoves the current position of this stream to a given byte offset (optional operation).- Specified by:
seekin interfaceBasicInput- Throws:
EOFException
-
getOffset
public long getOffset()Description copied from interface:BasicInputReturns the curent position in this stream (optional operation).- Specified by:
getOffsetin interfaceBasicInput
-
skip
Description copied from interface:BasicInputSkips a given number of bytes forwards through the stream. An exception is thrown if there are not enough bytes left.- Specified by:
skipin interfaceBasicInput- Parameters:
nbyte- number of bytes to skip- Throws:
IOException
-
readByte
Description copied from interface:BasicInputReads a byte from the stream. The current position is advanced.- Specified by:
readBytein interfaceBasicInput- Returns:
- byte value
- Throws:
EOFException
-
readShort
Description copied from interface:BasicInputReads a 2-byte integer from the stream. The current position is advanced.- Specified by:
readShortin interfaceBasicInput- Returns:
- short value
- Throws:
EOFException
-
readInt
Description copied from interface:BasicInputReads a 4-byte integer from the stream. The current position is advanced.- Specified by:
readIntin interfaceBasicInput- Returns:
- int value
- Throws:
EOFException
-
readLong
Description copied from interface:BasicInputReads an 8-byte integer from the stream. The current position is advanced.- Specified by:
readLongin interfaceBasicInput- Returns:
- long value
- Throws:
EOFException
-
readFloat
Description copied from interface:BasicInputReads a 4-byte floating point value from the stream. The current position is advanced.- Specified by:
readFloatin interfaceBasicInput- Returns:
- float value
- Throws:
EOFException
-
readDouble
Description copied from interface:BasicInputReads an 8-byte floating point value from the stream. The current position is advanced.- Specified by:
readDoublein interfaceBasicInput- Returns:
- double value
- Throws:
EOFException
-
readBytes
Description copied from interface:BasicInputReads bytes into an array from the stream. The current position is advanced.- Specified by:
readBytesin interfaceBasicInput- Parameters:
bbuf- array into which the bytes are read; the number of bytes read is the length of the array- Throws:
EOFException
-
close
public void close()Description copied from interface:BasicInputReleases resources belonging to this object. Attempts to use it after a call to this method result in undefined behaviour.- Specified by:
closein interfaceBasicInput
-