public class CleaningRandomAccessFile extends RandomAccessFile
RandomAccessFile that quietly closes itself during finalisation if it
has not already been closed. This guards against leaks when a test forgets to
close the file, although callers should still use try-with-resources wherever
possible.
Finalisation is deprecated in recent JDKs so this class is only a safety net for legacy code.
| Constructor and Description |
|---|
CleaningRandomAccessFile(File file,
String mode) |
CleaningRandomAccessFile(String name,
String mode) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
finalize() |
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, writeUTFpublic CleaningRandomAccessFile(String name, String mode) throws FileNotFoundException
FileNotFoundExceptionpublic CleaningRandomAccessFile(File file, String mode) throws FileNotFoundException
FileNotFoundExceptionCopyright © 2026 Chronicle Software Ltd. All rights reserved.