RandomAccessFile class abstract

Random access to the data in a file.

RandomAccessFile objects are obtained by calling the open method on a File object.

A RandomAccessFile has both asynchronous and synchronous methods. The asynchronous methods all return a Future whereas the synchronous methods will return the result directly, and block the current isolate until the result is ready.

At most one asynchronous method can be pending on a given RandomAccessFile instance at the time. If another asynchronous method is called when one is already in progress, a FileSystemException is thrown.

If an asynchronous method is pending, it is also not possible to call any synchronous methods. This will also throw a FileSystemException.

Constructors

RandomAccessFile()

Properties

hashCode int
The hash code for this object.
no setterinherited
path String
The path of the file underlying this random access file.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
Closes the file.
flush() Future<RandomAccessFile>
Flushes the contents of the file to disk.
length() Future<int>
Gets the length of the file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
position() Future<int>
Gets the current byte position in the file.
read(int count) Future<Uint8List>
Reads up to count bytes from a file.
readByte() Future<int>
Reads a byte from the file.
readInto(List<int> buffer, [int start = 0, int? end]) Future<int>
Reads bytes into an existing buffer.
setPosition(int position) Future<RandomAccessFile>
Sets the byte position in the file.
toString() String
A string representation of this object.
inherited
truncate(int length) Future<RandomAccessFile>
Truncates (or extends) the file to length bytes.
writeByte(int value) Future<RandomAccessFile>
Writes a single byte to the file.
writeFrom(List<int> buffer, [int start = 0, int? end]) Future<RandomAccessFile>
Writes from a buffer to the file.
writeString(String string, {Encoding encoding = utf8}) Future<RandomAccessFile>
Writes a string to the file using the given Encoding.

Operators

operator ==(Object other) bool
The equality operator.
inherited