Qore Programming Language Reference Manual  0.8.12.3
Qore::FileOutputStream Class Reference

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

Inheritance diagram for Qore::FileOutputStream:

Public Member Functions

nothing close ()
 Closes the output stream and releases any resources. More...
 
 constructor (string fileName, bool append=False, softint mode=0666)
 Creates the FileOutputStream by opening or creating a file. More...
 
nothing write (binary data)
 Writes bytes 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.13
Restrictions:
Qore::PO_NO_FILESYSTEM
Example: FileOutputStream basic usage
1 FileOutputStream fos("file.ext");
2 fos.write(<01>);
3 fos.write(<0203>);
4 fos.close();
5 # file.ext now contains three bytes: 01 02 03

Member Function Documentation

nothing Qore::FileOutputStream::close ( )
virtual

Closes the output stream and releases any resources.

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

Exceptions
IO-ERRORif an I/O error occurs

Implements Qore::OutputStream.

Qore::FileOutputStream::constructor ( string  fileName,
bool  append = False,
softint  mode = 0666 
)

Creates the FileOutputStream by opening or creating a file.

Parameters
fileNamethe name of the file to open
appendif true, then bytes will be written to the end of the file
modepermission bits for when the file is to be created (default: 0666)
nothing Qore::FileOutputStream::write ( binary  data)
virtual

Writes bytes to the output stream.

Parameters
datathe data to write
Example:
1 FileOutputStream fos("file.ext");
2 fos.write(<01>);
3 fos.write(<0203>);
4 fos.close();
5 # file.ext now contains three bytes: 01 02 03
Exceptions
FILE-WRITE-ERRORif an I/O error occurs

Implements Qore::OutputStream.