System.Classes.TStrings.SaveToStream

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure SaveToStream(Stream: TStream); overload; virtual;
procedure SaveToStream(Stream: TStream; Encoding: TEncoding); overload; virtual;

C++

virtual void __fastcall SaveToStream(TStream* Stream)/* overload */;
virtual void __fastcall SaveToStream(TStream* Stream, System::Sysutils::TEncoding* Encoding)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.Classes.pas
System.Classes.hpp
System.Classes TStrings

Description

Writes the value of the Text property to the Stream stream.

SaveToStream gets all strings from the current TStrings object and combines them into the single string containing these strings delimited by LineBreak sequence. Then SaveToStream encodes this string using the specified Encoding. Then SaveToStream writes the encoded string into the specified Stream stream.
If WriteBOM is True then SaveToStream first gets the preamble of the specified Encoding or of the DefaultEncoding (if Encoding = nil) and writes the preamble bytes into the stream before the main string.
If the Encoding parameter is not given, then the strings are saved with the encoding specified in the Encoding property.

Note: On Windows, the default LineBreak value is a carriage return and line feed combination (#13#10), whereas on macOS, it is just a line feed (#10).
Note: If TrailingLineBreak is True, then SaveToStream writes a finishing line break LineBreak after the last string.

If the stream is a file stream, SaveToStream does the same thing as SaveToFile, except that SaveToFile creates and destroys the file stream.

See Also

Code Examples