Unit 'Classes' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

TStream.Read

Reads data from the stream to a buffer and returns the number of bytes read.

Declaration

Source position: classesh.inc line 1246

public function TStream.Read(

  var Buffer;

  Count: LongInt

):LongInt; virtual; overload;

function TStream.Read(

  var Buffer: TBytes;

  Count: LongInt

):LongInt; overload;

function TStream.Read(

  Buffer: TBytes;

  aOffset: LongInt;

  Count: LongInt

):LongInt; overload;

Description

Read attempts to read Count from the stream to Buffer and returns the number of bytes actually read.

This method should be used when the number of bytes is not determined. If a specific number of bytes is expected, use TSTream.ReadBuffer instead.

As implemented in TStream, Read does nothing but raises an EStreamError exception to indicate that reading is not supported. Descendant classes that allow reading must override this method to do the actual reading.

Descendant classes should (if they don't explicitly raise an exception) return a positive value (>=0), where zero indicates an error.

Errors

In case a descendant class does not allow reading from the stream, an exception is raised.

See also

TStream.Write

  

Writes data from a buffer to the stream and returns the number of bytes written.

TStream.ReadBuffer

  

Reads data from the stream to a buffer.


Documentation generated on: Nov 23 2024