Class: JsLocalStorageFileStream

JsLocalStorageFileStream(file, mode)

An advanced file stream implementation for localStorage files. This class can be used to read and write small file in localStorage.

Constructor

new JsLocalStorageFileStream(file, mode)

Construct a file stream from an JsLocalStorageFile. This will create a wrapper stream that will route read() and write() to the FileChannel
Parameters:
Name Type Description
file The JsLocalStorageFile that will be used to get the read/write stream
mode The mode "r" for read "rw" for write
Source:

Classes

JsLocalStorageFileStream

Methods

(async) canRead()

True if stream can read from file.
Source:
Returns:

(async) canSeek()

True if stream can seek.
Source:
Returns:

(async) canWrite()

True if stream can write to file.
Source:
Returns:

(async) close()

Close this stream and associated resources.
Source:
Throws:
IOException Thrown if there is an IO error.

(async) flush()

Flush the buffers to the associated file.
Source:

(async) getPosition()

Get the current position of the stream.
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:

(async) length()

Get the length of the stream. This is the same as the backed file.
Source:
Returns:

(async) read(buffer, offset, count)

Read data from the file stream into the buffer provided.
Parameters:
Name Type Description
buffer The buffer to write the data.
offset The offset of the buffer to start writing the data.
count The maximum number of bytes to read from.
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:

(async) seek(offset, origin)

Seek to the offset provided.
Parameters:
Name Type Description
offset The position to seek to.
origin The type of origin RandomAccessStream.SeekOrigin
Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
The new position after seeking.

(async) setLength(value)

Set the length of the stream. This is applicable for write streams only.
Parameters:
Name Type Description
value The new length.
Source:
Throws:
IOException Thrown if there is an IO error.

(async) setPosition(value)

Set the current position of the stream.
Parameters:
Name Type Description
value The new position.
Source:
Throws:
IOException Thrown if there is an IO error.

(async) write(buffer, offset, count)

Write the data from the buffer provided into the stream.
Parameters:
Name Type Description
buffer The buffer to read the data from.
offset The offset of the buffer to start reading the data.
count The maximum number of bytes to read from the buffer.
Source:
Throws:
IOException Thrown if there is an IO error.