Qore Programming Language Reference Manual  0.8.12
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 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
1 FileOutputStream fos("file.ext");
2 fos.write(1);
3 fos.bulkWrite(<0203>);
4 fos.close();
5 # 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
datathe data to write
timeout_msignored
Example:
1 FileOutputStream fos("file.ext");
2 fos.bulkWrite(<01>);
3 fos.bulkWrite(<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.

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-ERRORif 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
fileNamethe name of the file to open
appendif 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
valuethe byte (0 - 255) to write to the output stream, only the least significant 8 bits are used, the rest is ignored
timeout_msignored
Example:
1 FileOutputStream fos("file.ext");
2 fos.write(1);
3 fos.write(2);
4 fos.write(3);
5 fos.close();
6 # file.ext now contains three bytes: 01 02 03
Exceptions
FILE-WRITE-ERRORif an I/O error occurs

Implements Qore::OutputStream.