Qore::FileOutputStream Class Reference

This class implements the OutputStream interface for writing bytes to a file. More...

Inheritance diagram for Qore::FileOutputStream:
[legend]

## Public Member Functions

nothing | bulkWrite (binary data, timeout timeout_ms=-1)
| Writes bytes to the input stream. More...
nothing | close ()
| Closes the output stream and releases any resources. More...
| constructor (string fileName, bool append=False)
| Creates the FileOutputStream by opening or creating a file. More...
nothing | write (int value, timeout timeout_ms=-1)
| Writes a single byte to the output stream. More...
Public Member Functions inherited from Qore::OutputStream
| constructor ()
| Constructor. More...

## Detailed Description

This class implements the OutputStream interface for writing bytes to a file.

Since
  Qore 0.8.12

Restrictions:
  Qore::PO_NO_FILESYSTEM

Example: FileOutputStream basic usage
  FileOutputStream fos("file.ext");
  fos.write(1);
  fos.bulkWrite(<0203>);
  fos.close();
  # file.ext now contains three bytes: 01 02 03

## Member Function Documentation

nothing Qore::FileOutputStream::bulkWrite | ( | binary | data,
|  | timeout | timeout_ms = `-1`
| ) |  |

virtual

Writes bytes to the input stream.

Parameters

  data | the data to write
  timeout_ms | ignored

Example:
  FileOutputStream fos("file.ext");
  fos.bulkWrite(<01>);
  fos.bulkWrite(<0203>);
  fos.close();
  # file.ext now contains three bytes: 01 02 03

Exceptions

  FILE-WRITE-ERROR | if an I/O error occurs

Implements Qore::OutputStream.

nothing Qore::FileOutputStream::close | ( |  | ) |

virtual

Closes the output stream and releases any resources.

Any methods called on a closed output stream will thrown an IO-ERROR exception.

Exceptions

  IO-ERROR | if an I/O error occurs

Implements Qore::OutputStream.

Qore::FileOutputStream::constructor | ( | string | fileName,
|  | bool | append = `False`
| ) |  |

Creates the FileOutputStream by opening or creating a file.

Parameters

  fileName | the name of the file to open
  append | if true, then bytes will be written to the end of the file

nothing Qore::FileOutputStream::write | ( | int | value,
|  | timeout | timeout_ms = `-1`
| ) |  |

virtual

Writes a single byte to the output stream.

Parameters

  value | the byte (0 - 255) to write to the output stream, only the least significant 8 bits are used, the rest is ignored
  timeout_ms | ignored

Example:
  FileOutputStream fos("file.ext");
  fos.write(1);
  fos.write(2);
  fos.write(3);
  fos.close();
  # file.ext now contains three bytes: 01 02 03

Exceptions

  FILE-WRITE-ERROR | if an I/O error occurs

Implements Qore::OutputStream.