\hypertarget{class_qore_1_1_file_output_stream}{}\doxysection{Qore\+::File\+Output\+Stream Class Reference} \label{class_qore_1_1_file_output_stream}\index{Qore::FileOutputStream@{Qore::FileOutputStream}} 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\+: % FIG 0 \doxysubsection*{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} \doxysubsection{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\+::\+PO\+\_\+\+NO\+\_\+\+FILESYSTEM}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+: File\+Output\+Stream basic usage} \begin{DoxyCode}{0} \DoxyCodeLine{FileOutputStream fos(\textcolor{stringliteral}{"{}file.ext"{}});} \DoxyCodeLine{fos.write(<01>);} \DoxyCodeLine{fos.write(<0203>);} \DoxyCodeLine{fos.close();} \DoxyCodeLine{\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 STREAM-\/\+THREAD-\/\+ERROR} 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} \doxysubsection{Member Function Documentation} \mbox{\Hypertarget{class_qore_1_1_file_output_stream_a40dc875e057e1820a81b4e6bcb22bb49}\label{class_qore_1_1_file_output_stream_a40dc875e057e1820a81b4e6bcb22bb49}} \index{Qore::FileOutputStream@{Qore::FileOutputStream}!close@{close}} \index{close@{close}!Qore::FileOutputStream@{Qore::FileOutputStream}} \doxysubsubsection{\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 IO-\/\+ERROR exception. \begin{DoxyExceptions}{Exceptions} {\em IO-\/\+ERROR} & if an I/O error occurs \\ \hline {\em OUTPUT-\/\+STREAM-\/\+CLOSED-\/\+ERROR} & the output stream has already been closed \\ \hline {\em STREAM-\/\+THREAD-\/\+ERROR} & 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::FileOutputStream@{Qore::FileOutputStream}!constructor@{constructor}} \index{constructor@{constructor}!Qore::FileOutputStream@{Qore::FileOutputStream}} \doxysubsubsection{\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::FileOutputStream@{Qore::FileOutputStream}!getEncoding@{getEncoding}} \index{getEncoding@{getEncoding}!Qore::FileOutputStream@{Qore::FileOutputStream}} \doxysubsubsection{\texorpdfstring{getEncoding()}{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}{CONSTANT}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{FileOutputStream fos(filname);} \DoxyCodeLine{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::FileOutputStream@{Qore::FileOutputStream}!write@{write}} \index{write@{write}!Qore::FileOutputStream@{Qore::FileOutputStream}} \doxysubsubsection{\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}{0} \DoxyCodeLine{FileOutputStream fos(\textcolor{stringliteral}{"{}file.ext"{}});} \DoxyCodeLine{fos.write(<01>);} \DoxyCodeLine{fos.write(<0203>);} \DoxyCodeLine{fos.close();} \DoxyCodeLine{\textcolor{comment}{\# file.ext now contains three bytes: 01 02 03}} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyExceptions}{Exceptions} {\em FILE-\/\+WRITE-\/\+ERROR} & if an I/O error occurs \\ \hline {\em OUTPUT-\/\+STREAM-\/\+CLOSED-\/\+ERROR} & the output stream has already been closed \\ \hline {\em STREAM-\/\+THREAD-\/\+ERROR} & 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}}.