This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

OpenRead

OpenRead
opens a file to read data from, and returns an InputStream object.
  • OpenRead prepares to read from a file, starting at the beginning of the file.
  • On systems that support pipes, OpenRead runs the external program specified by command, and opens a pipe to get input from it.
  • If OpenRead does not succeed in opening a particular file or pipe, it generates a message, and returns $Failed.
  • The function ReadList automatically opens files or pipes that it needs.
  • OpenRead returns InputStream, where name is the full name of a file or command, and n is a serial number that is unique across all streams opened in the current Mathematica session.
  • With the option BinaryFormat->True the stream is opened in binary format, so that no textual interpretation of newlines or other data is done.
Open a file:
Read the file:
Close the stream:
Open a file:
In[1]:=
Click for copyable input
Out[1]=
Read the file:
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
Close the stream:
In[5]:=
Click for copyable input
Out[5]=
New in 1 | Last modified in 6