This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Input and Output / File Output  /
Write

  • Write[ channel , , , ... ] writes the expressions in sequence, followed by a newline, to the specified output channel.
  • The output channel can be a single file or pipe, or list of them, each specified by a string giving their name, or by an OutputStream object.
  • Write is the basic Mathematica output function. Print and Message are defined in terms of it.
  • If any of the specified files or pipes are not already open, Write calls OpenWrite to open them.
  • Write does not close files and pipes after it finishes writing to them.
  • By default, Write generates output in the form specified by the setting of the FormatType option for the output stream used.
  • See the Mathematica book: Section 2.11.3.
  • See also: Print, Display, Message, Read, LinkWrite.

    Further Examples

    This open a stream to a file temps.

    In[1]:=

    Out[1]=

    This writes a sequence of expressions to the file.

    In[2]:=

    The expressions are written in input form.

    In[3]:=

    a^21 + b^2

    This writes another expression to the file.

    In[4]:=

    The expressions from a single Write are put on the same line.

    In[5]:=

    a^21 + b^2
    c^3

    This closes the stream.

    In[6]:=

    Out[6]=