Package com.aoindustries.io
Class FixedRecordFile
- java.lang.Object
-
- java.io.RandomAccessFile
-
- com.aoindustries.io.FixedRecordFile
-
- All Implemented Interfaces:
Closeable,DataInput,DataOutput,AutoCloseable
public class FixedRecordFile extends RandomAccessFile
A way to more easily manipulate files with fixed-record-size rows.- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description FixedRecordFile(File file, String mode, int recordLength)FixedRecordFile(String name, String mode, int recordLength)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecord(int index)voidaddRecords(int index, int numRecords)static voidcopyBytes(RandomAccessFile from, long fromIndex, RandomAccessFile to, long toIndex, long numBytes)static voidcopyRecords(FixedRecordFile from, long fromIndex, FixedRecordFile to, long toIndex, long numRecords)intgetRecordCount()intgetRecordLength()voidremoveAllRecords()voidremoveRecord(int index)voidseekToExistingRecord(int index)voidswap(int index1, int index2)-
Methods inherited from class java.io.RandomAccessFile
close, getChannel, getFD, getFilePointer, length, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
-
-
-
Constructor Detail
-
FixedRecordFile
public FixedRecordFile(String name, String mode, int recordLength) throws FileNotFoundException
- Throws:
FileNotFoundException
-
FixedRecordFile
public FixedRecordFile(File file, String mode, int recordLength) throws FileNotFoundException
- Throws:
FileNotFoundException
-
-
Method Detail
-
seekToExistingRecord
public void seekToExistingRecord(int index) throws IndexOutOfBoundsException, IOException- Throws:
IndexOutOfBoundsExceptionIOException
-
addRecord
public void addRecord(int index) throws IndexOutOfBoundsException, IOException- Throws:
IndexOutOfBoundsExceptionIOException
-
addRecords
public void addRecords(int index, int numRecords) throws IndexOutOfBoundsException, IOException- Throws:
IndexOutOfBoundsExceptionIOException
-
getRecordCount
public int getRecordCount() throws IOException- Throws:
IOException
-
copyBytes
public static void copyBytes(RandomAccessFile from, long fromIndex, RandomAccessFile to, long toIndex, long numBytes) throws IOException
- Throws:
IOException
-
copyRecords
public static void copyRecords(FixedRecordFile from, long fromIndex, FixedRecordFile to, long toIndex, long numRecords) throws IOException
- Throws:
IOException
-
removeAllRecords
public void removeAllRecords() throws IOException- Throws:
IOException
-
removeRecord
public void removeRecord(int index) throws IOException- Throws:
IOException
-
getRecordLength
public int getRecordLength()
-
swap
public void swap(int index1, int index2) throws IOException- Throws:
IOException
-
-