\hypertarget{class_qore_1_1_file_output_stream}{}\section{Qore\+:\+:File\+Output\+Stream Class Reference}
\label{class_qore_1_1_file_output_stream}\index{Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}}


This class implements the \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} interface for writing bytes to a file.  




Inheritance diagram for Qore\+:\+:File\+Output\+Stream\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=211pt]{class_qore_1_1_file_output_stream__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_output_stream_a40dc875e057e1820a81b4e6bcb22bb49}{close}} ()
\begin{DoxyCompactList}\small\item\em Closes the output stream and releases any resources. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_file_output_stream_aa431640a1a49b6e45f1c9d4ee784d1fa}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} file\+Name, bool append=\mbox{\hyperlink{group__boolean__constants_ga9da2b9a8003cd3788e48305f8a00540f}{False}}, softint mode=0644, \+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Creates the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}} by opening or creating a file. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_file_output_stream_a6682997dfb22ce5ea3ae6878e9c8b531}{get\+Encoding}} ()
\begin{DoxyCompactList}\small\item\em Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}}. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_output_stream_a92bead81e08e4a855c35d313b85a59cd}{write}} (\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} data)
\begin{DoxyCompactList}\small\item\em Writes bytes to the output stream. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class implements the \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} interface for writing bytes to a file. 

\begin{DoxyParagraph}{Restrictions\+:}
\mbox{\hyperlink{group__parse__options_ga5e466ed886222f0b57b0a399b455be71}{Qore\+::\+P\+O\+\_\+\+N\+O\+\_\+\+F\+I\+L\+E\+S\+Y\+S\+T\+EM}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+: File\+Output\+Stream basic usage}

\begin{DoxyCode}
FileOutputStream fos(\textcolor{stringliteral}{"file.ext"});
fos.write(<01>);
fos.write(<0203>);
fos.close();
\textcolor{comment}{# file.ext now contains three bytes: 01 02 03}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}
stream classes are not designed to be accessed from multiple threads; they have been implemented without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause a {\ttfamily S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} to be thrown, unless the stream is handed off to another thread using the \mbox{\hyperlink{class_qore_1_1_stream_base_a017fc847a42d5c670cb9640a94522666}{Stream\+Base\+:\+:unassign\+Thread()}} method in the thread that currently owns the stream, and the \mbox{\hyperlink{class_qore_1_1_stream_base_ab6b33cb1944c46aca8e9984ddfd65452}{Stream\+Base\+:\+:reassign\+Thread()}} method in the new thread.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_stream_writer}{Stream\+Writer}} for a class that can be used to \mbox{\hyperlink{class_qore_1_1_file_output_stream_a92bead81e08e4a855c35d313b85a59cd}{write}} various kinds of data to an \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}}
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+13 
\end{DoxySince}


\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_file_output_stream_a40dc875e057e1820a81b4e6bcb22bb49}\label{class_qore_1_1_file_output_stream_a40dc875e057e1820a81b4e6bcb22bb49}} 
\index{Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}!close@{close}}
\index{close@{close}!Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}}
\subsubsection{\texorpdfstring{close()}{close()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+Output\+Stream\+::close (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Closes the output stream and releases any resources. 

Any methods called on a closed output stream will throw an I\+O-\/\+E\+R\+R\+OR exception.


\begin{DoxyExceptions}{Exceptions}
{\em I\+O-\/\+E\+R\+R\+OR} & if an I/O error occurs \\
\hline
{\em O\+U\+T\+P\+U\+T-\/\+S\+T\+R\+E\+A\+M-\/\+C\+L\+O\+S\+E\+D-\/\+E\+R\+R\+OR} & the output stream has already been closed \\
\hline
{\em S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}


Implements \mbox{\hyperlink{class_qore_1_1_output_stream_a2125e17612767b9636554b282638e883}{Qore\+::\+Output\+Stream}}.

\mbox{\Hypertarget{class_qore_1_1_file_output_stream_aa431640a1a49b6e45f1c9d4ee784d1fa}\label{class_qore_1_1_file_output_stream_aa431640a1a49b6e45f1c9d4ee784d1fa}} 
\index{Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}!constructor@{constructor}}
\index{constructor@{constructor}!Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}}
\subsubsection{\texorpdfstring{constructor()}{constructor()}}
{\footnotesize\ttfamily Qore\+::\+File\+Output\+Stream\+::constructor (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{file\+Name,  }\item[{bool}]{append = {\ttfamily \mbox{\hyperlink{group__boolean__constants_ga9da2b9a8003cd3788e48305f8a00540f}{False}}},  }\item[{softint}]{mode = {\ttfamily 0644},  }\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Creates the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}} by opening or creating a file. 


\begin{DoxyParams}{Parameters}
{\em file\+Name} & the name of the file to open \\
\hline
{\em append} & if true, then bytes will be written to the end of the file \\
\hline
{\em mode} & permission bits for when the file is to be created (default\+: 0644) \\
\hline
{\em encoding} & the \mbox{\hyperlink{character_encoding}{character encoding}} of the file; if not present, defaults to the \mbox{\hyperlink{character_encoding_default_encoding}{default encoding}}\\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}} object 
\end{DoxyNote}
\mbox{\Hypertarget{class_qore_1_1_file_output_stream_a6682997dfb22ce5ea3ae6878e9c8b531}\label{class_qore_1_1_file_output_stream_a6682997dfb22ce5ea3ae6878e9c8b531}} 
\index{Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}!get\+Encoding@{get\+Encoding}}
\index{get\+Encoding@{get\+Encoding}!Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}}
\subsubsection{\texorpdfstring{get\+Encoding()}{getEncoding()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+File\+Output\+Stream\+::get\+Encoding (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}}. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
FileOutputStream fos(filname);
string encoding = fos.getEncoding();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}}
\end{DoxyReturn}
\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}} object 
\end{DoxyNote}
\mbox{\Hypertarget{class_qore_1_1_file_output_stream_a92bead81e08e4a855c35d313b85a59cd}\label{class_qore_1_1_file_output_stream_a92bead81e08e4a855c35d313b85a59cd}} 
\index{Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}!write@{write}}
\index{write@{write}!Qore\+::\+File\+Output\+Stream@{Qore\+::\+File\+Output\+Stream}}
\subsubsection{\texorpdfstring{write()}{write()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+Output\+Stream\+::write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}}}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Writes bytes to the output stream. 


\begin{DoxyParams}{Parameters}
{\em data} & the data to write\\
\hline
\end{DoxyParams}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
FileOutputStream fos(\textcolor{stringliteral}{"file.ext"});
fos.write(<01>);
fos.write(<0203>);
fos.close();
\textcolor{comment}{# file.ext now contains three bytes: 01 02 03}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & if an I/O error occurs \\
\hline
{\em O\+U\+T\+P\+U\+T-\/\+S\+T\+R\+E\+A\+M-\/\+C\+L\+O\+S\+E\+D-\/\+E\+R\+R\+OR} & the output stream has already been closed \\
\hline
{\em S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} & this exception is thrown if this method is called from any thread other than the thread that created the object\\
\hline
\end{DoxyExceptions}
\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_file_output_stream}{File\+Output\+Stream}} object 
\end{DoxyNote}


Implements \mbox{\hyperlink{class_qore_1_1_output_stream_a9054b0475c4829d10f956d8f6df6f2ac}{Qore\+::\+Output\+Stream}}.

