Packageat.fhjoanneum.dmt.umj.core.util.core
Classpublic class FileStreamWithLineReader
InheritanceFileStreamWithLineReader Inheritance flash.filesystem.FileStream

Since : 17 Dec 2010

Helper: An extension of the flash.filesystem.FileStream object that supports reading lines from the inherent file stream. The objects uses an internal buffer so as not to hit the performance. The default buffer size is 512 bytes. The object supports only standard methods of the underlying FileStream object. Usage of the class is only recommended when one tends to read the data line by line from a file stream. If the readUTFLine() or readMultiByteLine() methods are not intended to be called, it will be preferable to use the FileStream object, for performance reasons only.



Public Properties
 PropertyDefined By
  bytesAvailable : uint
[override] [read-only] Returns the number of bytes of data available for reading in the input buffer.
FileStreamWithLineReader
  position : Number
[override] The current position in the buffer/file where the next read will happen.
FileStreamWithLineReader
Protected Properties
 PropertyDefined By
  bytesToRead : uint
[read-only] Method that returns the number of bytes that can be read in the next read over the actual file stream.
FileStreamWithLineReader
  hasBuffer : Boolean
[read-only] Utility method to see if check if we have data in our internal buffer.
FileStreamWithLineReader
Public Methods
 MethodDefined By
  
Constructor
FileStreamWithLineReader
  
readBoolean():Boolean
[override] Overriden parent class functions to support buffering
FileStreamWithLineReader
  
readByte():int
[override]
FileStreamWithLineReader
  
readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
[override]
FileStreamWithLineReader
  
readDouble():Number
[override]
FileStreamWithLineReader
  
readFloat():Number
[override]
FileStreamWithLineReader
  
readInt():int
[override]
FileStreamWithLineReader
  
readLine(charSet:String):String
Method that actually attempts to read a line from the inherent file stream using internal buffers in the given encoding.
FileStreamWithLineReader
  
readMultiByteLine(charSet:String):String
Reads a line in the specified encoding from the inherent file stream.
FileStreamWithLineReader
  
[override]
FileStreamWithLineReader
  
readShort():int
[override]
FileStreamWithLineReader
  
[override]
FileStreamWithLineReader
  
[override]
FileStreamWithLineReader
  
[override]
FileStreamWithLineReader
  
readUTF():String
[override]
FileStreamWithLineReader
  
readUTFBytes(length:uint):String
[override]
FileStreamWithLineReader
  
readUTFLine():String
Reads a UTF-8 encoded line from the inherent file stream.
FileStreamWithLineReader
  
setBufferSize(value:uint):void
Set the buffer size to the given value.
FileStreamWithLineReader
Protected Methods
 MethodDefined By
  
Method to refill the buffer again with data from the file stream.
FileStreamWithLineReader
  
undoBuffer():void
Method to clean up the current buffer and move back in the original stream by the extra bytes that were buffered in.
FileStreamWithLineReader
Property Detail
bytesAvailableproperty
bytesAvailable:uint  [read-only] [override]

Returns the number of bytes of data available for reading in the input buffer.


Implementation
    public function get bytesAvailable():uint
bytesToReadproperty 
bytesToRead:uint  [read-only]

Method that returns the number of bytes that can be read in the next read over the actual file stream. The value is the lesser amongst the buffer size and the actual number of bytes available in the file stream.


Implementation
    protected function get bytesToRead():uint
hasBufferproperty 
hasBuffer:Boolean  [read-only]

Utility method to see if check if we have data in our internal buffer.


Implementation
    protected function get hasBuffer():Boolean
positionproperty 
position:Number[override]

The current position in the buffer/file where the next read will happen.


Implementation
    public function get position():Number
    public function set position(value:Number):void
Constructor Detail
FileStreamWithLineReader()Constructor
public function FileStreamWithLineReader()

Constructor

Method Detail
readBoolean()method
override public function readBoolean():Boolean

Overriden parent class functions to support buffering

Returns
Boolean
readByte()method 
override public function readByte():int

Returns
int
readBytes()method 
override public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

Parameters

bytes:ByteArray
 
offset:uint (default = 0)
 
length:uint (default = 0)

readDouble()method 
override public function readDouble():Number

Returns
Number
readFloat()method 
override public function readFloat():Number

Returns
Number
readInt()method 
override public function readInt():int

Returns
int
readLine()method 
public function readLine(charSet:String):String

Method that actually attempts to read a line from the inherent file stream using internal buffers in the given encoding. If no line termination character is found, the entire stream from the current position to the end-of-file is returned back.

Parameters

charSet:String

Returns
String
readMultiByteLine()method 
public function readMultiByteLine(charSet:String):String

Reads a line in the specified encoding from the inherent file stream. The presence of a line termination character '\n' indicates the end-of-line.

Parameters

charSet:String

Returns
String
readObject()method 
override public function readObject():*

Returns
*
readShort()method 
override public function readShort():int

Returns
int
readUnsignedByte()method 
override public function readUnsignedByte():uint

Returns
uint
readUnsignedInt()method 
override public function readUnsignedInt():uint

Returns
uint
readUnsignedShort()method 
override public function readUnsignedShort():uint

Returns
uint
readUTF()method 
override public function readUTF():String

Returns
String
readUTFBytes()method 
override public function readUTFBytes(length:uint):String

Parameters

length:uint

Returns
String
readUTFLine()method 
public function readUTFLine():String

Reads a UTF-8 encoded line from the inherent file stream. The presence of a line termination character '\n' indicates the end-of-line.

Returns
String
refillBuffer()method 
protected function refillBuffer():void

Method to refill the buffer again with data from the file stream. The buffer is either filled with the number of bytes as returned by the bytesToRead() method.

setBufferSize()method 
public function setBufferSize(value:uint):void

Set the buffer size to the given value. A value of ZERO will reset the buffer size to a default value of 512 bytes.

Parameters

value:uint

undoBuffer()method 
protected function undoBuffer():void

Method to clean up the current buffer and move back in the original stream by the extra bytes that were buffered in.