class Poco::FileOutputStream

Overview

An output stream for writing to a file. More…

#include <FileStream.h>

class FileOutputStream:
    public Poco::FileIOS,
    public ostream
{
public:
    // construction

    FileOutputStream();

    FileOutputStream(
        const std::string& path,
        std::ios::openmode mode = std::ios::out|std::ios::trunc
        );
};

Inherited Members

public:
    // methods

    void
    open(
        const std::string& path,
        std::ios::openmode mode
        );

    void
    close();

    FileStreamBuf*
    rdbuf();

protected:
    // fields

    FileStreamBuf _buf;
    std::ios::openmode _defaultMode;

Detailed Documentation

An output stream for writing to a file.

Files are always opened in binary mode, a text mode with CR-LF translation is not supported. Thus, the file is always opened as if the std::ios::binary flag was specified. Use an OutputLineEndingConverter if you require CR-LF translation.

On Windows platforms, if POCO_WIN32_UTF8 is #define’d, UTF-8 encoded Unicode paths are correctly handled.

Construction

FileOutputStream()

Creats an unopened FileOutputStream.

FileOutputStream(
    const std::string& path,
    std::ios::openmode mode = std::ios::out|std::ios::trunc
    )

Creates the FileOutputStream for the file given by path, using the given mode.

The std::ios::out is always set, regardless of the actual value specified for mode.

Throws a FileException (or a similar exception) if the file does not exist or is not accessible for other reasons and a new file cannot be created.