[Overview][Constants][Classes][Index] | Reference for unit 'bufstream' (#fcl)

# TBufferedFileStream

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Implements a buffered file stream with a multi-page buffer

## Declaration

Source position: bufstream.pp line 81

`type TBufferedFileStream = class(TFileStream)`
`public`
`constructor Create();` |  | Constructor for the class instance
`destructor Destroy; override;` |  | Destructor for the class instance
`function Seek();` |  | Moves the position in the buffer relative to the specified origin
`function Read(); override;` |  | Reads the specified number of bytes into the Buffer parameter
`function Write(); override;` |  | Writes the specified number of bytes in Buffer to the internal page buffer(s)
`procedure Flush;` |  | Flushes modified pages in the buffer to the file stream
`procedure InitializeCache();` |  | Re-initializes the internal buffer for the buffered file stream
`end;`

## Inheritance

`TBufferedFileStream` |  | Implements a buffered file stream with a multi-page buffer
`TFileStream`
`THandleStream`
`TStream`
`TObject`

## Description

TBufferedFileStream is a TFileStream descendant which implements a buffered file stream. It provides a buffer with multiple pages used for random read / write access in the file stream.

By default, It uses a fixed-size buffer consisting of 8 pages with a 4,096 bytes per page. Both page count and page size configurable using methods in the class. The buffer is automatically maintained when the stream size or position is changed, and when reading or writing content to/from the stream.

Pages which have been modified in the buffer are written to the file stream as needed, when the Flush method is called, and when the class instance is freed.

## See also

TFileStream
THandleStream
TStream