Package uk.ac.starlink.oldfits
Class MultiMappedFile
java.lang.Object
uk.ac.starlink.oldfits.AbstractArrayDataIO
uk.ac.starlink.oldfits.MultiMappedFile
- All Implemented Interfaces:
Closeable,DataInput,DataOutput,AutoCloseable,nom.tam.util.ArrayDataInput,nom.tam.util.ArrayDataOutput,nom.tam.util.FitsIO,nom.tam.util.RandomAccess
ArrayDataIO implementation which works by mapping but is capable of
splitting a file up into multiple mapped sections. This will be
necessary if it's larger than Integer.MAX_VALUE bytes, though note
that doing this is only going to be a good idea on a 64-bit OS.
- Since:
- 9 Jan 2007
- Author:
- Mark Taylor
-
Field Summary
Fields inherited from interface nom.tam.util.FitsIO
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK -
Constructor Summary
ConstructorsConstructorDescriptionMultiMappedFile(File file, FileChannel.MapMode mode, int blockBytes) Constructs a MultiMappedFile from a file.MultiMappedFile(FileChannel chan, FileChannel.MapMode mode, int blockBytes) Constructs a MultiMappedFile from a channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()protected byteget()Reads one byte from the current position.protected voidget(byte[] buf, int offset, int length) Reads bytes into a buffer from the current position.longlonglength()Returns the size of this buffer.voidmark(int readlimit) booleanprotected voidput(byte b) Writes a single byte at the current position.protected voidput(byte[] buf, int offset, int length) Writes bytes from a buffer to the current position.protected longReturns the number of bytes remaining between the current position and the end of the file.voidreset()voidseek(long offsetFromStart) longskip(long nskip) voidskipAllBytes(int toSkip) voidskipAllBytes(long nskip) intskipBytes(int toSkip) Methods inherited from class uk.ac.starlink.oldfits.AbstractArrayDataIO
read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readArray, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLArray, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, write, writeArray, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nom.tam.util.ArrayDataInput
read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, read, readArray, readFully, readLArrayMethods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF
-
Constructor Details
-
MultiMappedFile
public MultiMappedFile(FileChannel chan, FileChannel.MapMode mode, int blockBytes) throws IOException Constructs a MultiMappedFile from a channel.- Parameters:
chan- file channelmode- mapping modeblockBytes- number of bytes per mapped block (though the final one may have fewer)- Throws:
IOException
-
MultiMappedFile
Constructs a MultiMappedFile from a file.- Parameters:
file- filemode- mapping modeblockBytes- number of bytes per mapped block (though the final one may have fewer)- Throws:
IOException
-
-
Method Details
-
seek
- Specified by:
seekin interfacenom.tam.util.RandomAccess- Throws:
IOException
-
skip
- Specified by:
skipin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
skipAllBytes
- Specified by:
skipAllBytesin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
skipAllBytes
- Specified by:
skipAllBytesin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
getFilePointer
public long getFilePointer()- Specified by:
getFilePointerin interfacenom.tam.util.RandomAccess
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
markSupported
public boolean markSupported() -
mark
public void mark(int readlimit) - Specified by:
markin interfacenom.tam.util.ArrayDataInput
-
reset
- Specified by:
resetin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
get
Description copied from class:AbstractArrayDataIOReads one byte from the current position.- Specified by:
getin classAbstractArrayDataIO- Returns:
- next byte
- Throws:
IOException
-
get
Description copied from class:AbstractArrayDataIOReads bytes into a buffer from the current position.- Specified by:
getin classAbstractArrayDataIO- Parameters:
buf- destination bufferoffset- offset of first byte inbufto be writtenlength- maximum number of bytes to be written tobuf- Throws:
IOException
-
put
Description copied from class:AbstractArrayDataIOWrites a single byte at the current position.- Specified by:
putin classAbstractArrayDataIO- Parameters:
b- output byte- Throws:
IOException
-
put
Description copied from class:AbstractArrayDataIOWrites bytes from a buffer to the current position.- Specified by:
putin classAbstractArrayDataIO- Parameters:
buf- source bufferoffset- offset of first byte inbufto be readlength- number of bytes frombufto be read- Throws:
IOException
-
length
public long length()Description copied from class:AbstractArrayDataIOReturns the size of this buffer. May be -1 if not known/unlimited.- Specified by:
lengthin classAbstractArrayDataIO- Returns:
- length or -1
-
remaining
protected long remaining()Description copied from class:AbstractArrayDataIOReturns the number of bytes remaining between the current position and the end of the file. If there is no end to the file, it is permissible to returnLong.MAX_VALUE;- Specified by:
remainingin classAbstractArrayDataIO- Returns:
- number of bytes left in file
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacenom.tam.util.FitsIO- Throws:
IOException
-
flush
public void flush()- Specified by:
flushin interfacenom.tam.util.ArrayDataOutput
-