Package nom.tam.util
Interface RandomAccessFileIO
- All Superinterfaces:
AutoCloseable
,Closeable
,InputReader
,OutputWriter
,ReadWriteAccess
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 int
read
(byte[] bytes) Reads data, fully populating the supplied array.readUTF()
SeeRandomAccessFile.readUTF()
for a contract of this method.void
setLength
(long length) SeeRandomAccessFile.setLength(long)
for a contract of this method.default void
write
(byte[] bytes) Write all data from the the supplied array.void
SeeRandomAccessFile.writeUTF(String)
for a contract of this method.Methods inherited from interface nom.tam.util.InputReader
read, read
Methods inherited from interface nom.tam.util.OutputWriter
write, write
Methods inherited from interface nom.tam.util.ReadWriteAccess
length, position, position
-
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:
-