Class RandomAccessFileRAF
java.lang.Object
com.semedy.reasoner.edb.persistentstore.RandomAccessFileRAF
- All Implemented Interfaces:
RandomAccessToFile
A ramdom acess file paged. It provides a linear address room
- Author:
- juergen
-
Constructor Summary
ConstructorDescriptionRandomAccessFileRAF
(String filePath, String accessRights) creates a new file with given filepath and access rights "r" for read,
"rw" for read and write -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkFile
(long position, int len) check file contentsvoid
close()
close filevoid
delete()
void
flush()
flush filelong
get the current position of the filelong
length()
Get the file lengthvoid
read
(byte[] bytes) Reads a byte array from current position.void
read
(byte[] bytes, int offset, int len) Reads len bytes from current file position to array from offset position on.byte
readByte()
Reads a byte from current position.int
readInt()
Reads an int at current position.long
readLong()
Reads a long at current position.void
seek
(long position) Positions to an addressvoid
write
(byte[] bytes) Writes a byte array to current position.void
write
(byte[] bytes, int offset, int len) Writes len bytes from byte array from offset position on to current file position.void
writeByte
(int b) Reads a byte current positionvoid
writeInt
(int value) Writes an int to current position.void
writeLong
(long value) Writes a long to current position.
-
Constructor Details
-
RandomAccessFileRAF
creates a new file with given filepath and access rights "r" for read,
"rw" for read and write- Parameters:
filePath
-accessRights
-- Throws:
IOException
-
RandomAccessFileRAF
-
-
Method Details
-
seek
Positions to an address- Specified by:
seek
in interfaceRandomAccessToFile
- Parameters:
position
-- Throws:
IOException
-
read
Reads a byte array from current position.- Specified by:
read
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
read
Reads len bytes from current file position to array from offset position on.- Specified by:
read
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
write
Writes a byte array to current position.- Specified by:
write
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
write
Writes len bytes from byte array from offset position on to current file position.- Specified by:
write
in interfaceRandomAccessToFile
- Parameters:
bytes
-- Throws:
IOException
-
readInt
Reads an int at current position.- Specified by:
readInt
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeInt
Writes an int to current position. Creates an exception if byte array crosses a page border- Specified by:
writeInt
in interfaceRandomAccessToFile
- Parameters:
value
-- Throws:
IOException
-
close
close file- Specified by:
close
in interfaceRandomAccessToFile
- Throws:
IOException
-
flush
flush file- Specified by:
flush
in interfaceRandomAccessToFile
- Throws:
IOException
-
readLong
Reads a long at current position. Creates an exception if byte array crosses a page border- Specified by:
readLong
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeLong
Writes a long to current position. Creates an exception if byte array crosses a page border- Specified by:
writeLong
in interfaceRandomAccessToFile
- Parameters:
value
-- Throws:
IOException
-
length
Get the file length- Specified by:
length
in interfaceRandomAccessToFile
- Throws:
IOException
-
delete
- Specified by:
delete
in interfaceRandomAccessToFile
- Throws:
IOException
-
getFilePointer
Description copied from interface:RandomAccessToFile
get the current position of the file- Specified by:
getFilePointer
in interfaceRandomAccessToFile
- Returns:
- Throws:
IOException
-
readByte
Description copied from interface:RandomAccessToFile
Reads a byte from current position.- Specified by:
readByte
in interfaceRandomAccessToFile
- Throws:
IOException
-
writeByte
Description copied from interface:RandomAccessToFile
Reads a byte current position- Specified by:
writeByte
in interfaceRandomAccessToFile
- Throws:
IOException
-
checkFile
Description copied from interface:RandomAccessToFile
check file contents- Specified by:
checkFile
in interfaceRandomAccessToFile
- Returns:
- Throws:
IOException
-