Class FileStream

Object
   |
   +--FileStream

class FileStream


A FileStream allows reading or writing specific parts of a File.

The FileStream class exposes several ways of reading from and writing to Files. Examples include reading and writing bytes, strings and lines.

When the FileStream is created a pointer is usually set at the beginning of the file. As the read methods are called, the pointer moves through the file. Subsequent calls to the read methods read from that point and onward. When the end of the file is reached, the eof property is set to true.

This class supports Base64 data for use in cases like XMLHttpRequest. This object does not support writing binary data, so the Base64 methods can be used to write binary data encoded as strings.

By default, the FileStream object uses an UTF-8 encoding when writing. You can change this by setting the encoding property of the FileStream or by supplying a charset argument to the various methods that write characters.


Defined in file-io.js


Field Summary
 int bytesAvailable
          Number of of bytes available from the current position to the end of the FileStream.
 String encoding
          The encoding of this FileStream.
 boolean eof
          Whether or not the end of the FileStream has been reached.
 String newLine
          Newline character used for this particular FileStream.
 int position
          The current byte index position of this FileStream.
 String systemNewLine
          The system default character for separating lines in a file.
 
Constructor Summary
FileStream()
            This class has no public constructor.
 
Method Summary
 void close( )
           Close the FileStream for reading or writing.
 String read( <int> length, <String> charset )
           Read a number of characters from the FileStream.
 String readBase64( <int> length )
           Read bytes from the FileStream and encode it as Base64
 ByteArray readBytes( <int> length )
           Read a number of bytes from the FileStream
 String readLine( <String> charset )
           Read a line of characters from the FileStream
 void write( <String> string, <String> charset )
           Write a string of characters to the FileStream
 void writeBase64( <String> string )
           Decode a Base64 encoded string and write the data to the FileStream.
 void writeBytes( <ByteArray> bytes, <int> length )
           Write a set of bytes to the FileStream
 void writeFile( <File> file )
           Write a File to the FileStream.
 void writeImage( <HTMLImageElement> image )
           Write an image to the FileStream.
 void writeLine( <String> string, <String> charset )
           Write a line of characters to the FileStream

Field Detail

bytesAvailable

int bytesAvailable

encoding

String encoding

eof

boolean eof

newLine

String newLine

position

int position

systemNewLine

String systemNewLine

Constructor Detail

FileStream

FileStream()

Method Detail

close

void close( )

read

String read( <int> length, <String> charset )

readBase64

String readBase64( <int> length )

readBytes

ByteArray readBytes( <int> length )

readLine

String readLine( <String> charset )

write

void write( <String> string, <String> charset )

writeBase64

void writeBase64( <String> string )

writeBytes

void writeBytes( <ByteArray> bytes, <int> length )

writeFile

void writeFile( <File> file )

writeImage

void writeImage( <HTMLImageElement> image )

writeLine

void writeLine( <String> string, <String> charset )


Documentation generated by JSDoc on Fri Jan 29 17:08:19 2010