readAsText method

Reads a File, Blob, or MSStream object into memory as a text string.

Syntax

object.readAsText(object, length, encoding)

Parameters

object [in]

Type: File, Blob, or MSStream

length [in, optional]

Type: Number

encoding [in, optional]

Type: String

Remarks

When invoked from a MSStreamReader or FileReader object, this method does not return a value. When invoked from a FileReaderSync object, this method returns a string representing the data that was read.

var text = FileReaderSync.readAsText(blob, encoding);
FileReader.readAsText(blob, encoding);
MSStreamReader.readAsText(msstream, encoding, length);

When invoked from an MSStreamReader or FileReader object, this method asynchronously starts reading the contents of the specified File, Blob or MSStream object. When the read operation is complete, the readyState property is set to DONE and the onloadend event is fired. At that time, the result property contains a string representing the data that was read.

When invoked from an MSStreamReader object, the optional length parameter specifies the number of bytes that are read from the specified MSStream object. If the length parameter isn't specified, the read operation will continue until the end of the MSStream object is reached.

When invoked from a FileReaderSync object, this method synchronously reads the contents of the specified File or Blob. The method returns a string representing the data that was read.

See also

FileReader
FileReaderSync
MSStreamReader

 

 

Show:
© 2014 Microsoft