Dart API Referencedart:ioRandomAccessFile

RandomAccessFile Interface

RandomAccessFile provides random access to the data in a file. RandomAccessFile objects are obtained by calling the open method on a File object.

Methods

Code Future<RandomAccessFile> close() #

Close the file. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when it has been closed.

Future<RandomAccessFile> close();

Code void closeSync() #

Synchronously close the file.

void closeSync();

Code Future<RandomAccessFile> flush() #

Flush the contents of the file to disk. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the flush operation completes.

Future<RandomAccessFile> flush();

Code void flushSync() #

Synchronously flush the contents of the file to disk.

void flushSync();

Code Future<int> length() #

Get the length of the file. Returns a Future<int> that completes with the length in bytes.

Future<int> length();

Code int lengthSync() #

Synchronously get the length of the file.

int lengthSync();

Code String get name() #

Get the name of the file.

String get name();

Code Future<int> position() #

Get the current byte position in the file. Returns a Future<int> that completes with the position.

Future<int> position();

Code int positionSync() #

Synchronously get the current byte position in the file.

int positionSync();

Code Future<int> readByte() #

Read a byte from the file. Returns a Future<int> that completes with the byte or -1 if end of file has been reached.

Future<int> readByte();

Code int readByteSync() #

Synchronously read a single byte from the file. If end of file has been reached -1 is returned.

int readByteSync();

Code Future<int> readList(List<int> buffer, int offset, int bytes) #

Read a List<int> from the file. Returns a Future<int> that completes with an indication of how much was read.

Future<int> readList(List<int> buffer, int offset, int bytes);

Code int readListSync(List<int> buffer, int offset, int bytes) #

Synchronously read a List<int> from the file. Returns the number of bytes read.

int readListSync(List<int> buffer, int offset, int bytes);

Code Future<RandomAccessFile> setPosition(int position) #

Set the byte position in the file. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the position has been set.

Future<RandomAccessFile> setPosition(int position);

Code void setPositionSync(int position) #

Synchronously set the byte position in the file.

void setPositionSync(int position);

Code Future<RandomAccessFile> truncate(int length) #

Truncate (or extend) the file to length bytes. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the truncation has been performed.

Future<RandomAccessFile> truncate(int length);

Code void truncateSync(int length) #

Synchronously truncate (or extend) the file to length bytes.

void truncateSync(int length);

Code Future<RandomAccessFile> writeByte(int value) #

Write a single byte to the file. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the write completes.

Future<RandomAccessFile> writeByte(int value);

Code int writeByteSync(int value) #

Synchronously write a single byte to the file. Returns the number of bytes successfully written.

int writeByteSync(int value);

Code Future<RandomAccessFile> writeList(List<int> buffer, int offset, int bytes) #

Write a List<int> to the file. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the write completes.

Future<RandomAccessFile> writeList(List<int> buffer, int offset, int bytes);

Code int writeListSync(List<int> buffer, int offset, int bytes) #

Synchronously write a List<int> to the file. Returns the number of bytes successfully written.

int writeListSync(List<int> buffer, int offset, int bytes);

Code Future<RandomAccessFile> writeString(String string, [Encoding encoding]) #

Write a string to the file using the given encoding. The default encoding is UTF-8 - Encoding.UTF_8. Returns a Future<RandomAccessFile> that completes with this RandomAccessFile when the write completes.

Future<RandomAccessFile> writeString(String string, [Encoding encoding]);

Code int writeStringSync(String string, [Encoding encoding]) #

Synchronously write a single string to the file using the given encoding. Returns the number of characters successfully written. The default encoding is UTF-8 - Encoding.UTF_8.

int writeStringSync(String string, [Encoding encoding]);