Interface RandomAccessFileIO
- All Superinterfaces:
AutoCloseable, Closeable, InputReader, OutputWriter, ReadWriteAccess
- All Known Implementing Classes:
RandomAccessFileChannel
Interface for IO objects that support file-like random access. The methods defined here are those used by FitsFile to
access a RandomAccessFile. The RandomAccessFileExt class adds this interface to RandomAccessFile, but other systems
could provide an alternate implementation of this interface to access an arbitrary FITS data object.
- Author:
- pdowler
-
Method Summary
Modifier and TypeMethodDescriptionObtain the current FileChannel instance.getFD()Obtain the current FileDescriptor instance.default intread(byte[] bytes) Reads data, fully populating the supplied array.readUTF()SeeRandomAccessFile.readUTF()for a contract of this method.voidsetLength(long length) SeeRandomAccessFile.setLength(long)for a contract of this method.default voidwrite(byte[] bytes) Write all data from the the supplied array.voidSeeRandomAccessFile.writeUTF(String)for a contract of this method.Methods inherited from interface InputReader
read, readMethods inherited from interface OutputWriter
write, writeMethods inherited from interface ReadWriteAccess
length, position, positionModifier and TypeMethodDescriptionlonglength()Returns the current total length of this instance, that is the total number of bytes that may be read from it.longposition()Returns the current read/write position in this instance.voidposition(long n) Sets a new position for the next read or write in this instance.
-
Method Details
-
read
Reads data, fully populating the supplied array.- Parameters:
bytes- An array which to fill with data from the input- Returns:
- The number of bytes read, which may be fewer than the destination array size.
- Throws:
IOException- if there was an error reading the requisite data from the input- See Also:
-
readUTF
SeeRandomAccessFile.readUTF()for a contract of this method.- Returns:
- Reads a UTF string from the input, up to an EOL termination (with
\n) or until the end of file, whichever comes first. - Throws:
IOException- if there was an error reading the requisite data from the input- See Also:
-
getChannel
FileChannel getChannel()Obtain the current FileChannel instance. For instances that do not use File backed sources- Returns:
- FileChannel instance, possibly null.
- See Also:
-
getFD
Obtain the current FileDescriptor instance.- Returns:
- FileDescriptor instance, or possibly null.
- Throws:
IOException- For any I/O errors.- See Also:
-
write
Write all data from the the supplied array.- Parameters:
bytes- the data array- Throws:
IOException- if there was an error writing the data to the output- See Also:
-
setLength
SeeRandomAccessFile.setLength(long)for a contract of this method.- Parameters:
length- The new file length.- Throws:
IOException- if there was an error executing the request.- See Also:
-
writeUTF
SeeRandomAccessFile.writeUTF(String)for a contract of this method.- Parameters:
s- A java string.- Throws:
IOException- if there was an error writing the requisite data to the output- See Also:
-