Files and Streams

File Names

name.mMathematica language source file
name.nbMathematica notebook file
name.maMathematica notebook file from before Version 3
name.mxMathematica expression dump
name.exeMathLink executable program
name.tmMathLink template file
name.mlMathLink stream file

Conventions for file names.

Most files used by Mathematica are completely system independent. .mx and .exe files are however system dependent. For these files, there is a convention that bundles of versions for different computer systems have names with forms such as name/$SystemID/name.

In general, when you refer to a file, Mathematica tries to resolve its name as follows:

  • If the name starts with , Mathematica treats the remainder of the name as an external command, and uses a pipe to this command.
  • If the name starts with or Mathematica treats the name as a URL reads the file from a web server.
  • If the name is handled by a registered stream method, the method will open the stream using the name.
  • If the name contains metacharacters used by your operating system, then Mathematica passes the name directly to the operating system for interpretation.
  • Unless the file is to be used for input, no further processing on the name is done.
  • Unless the name given is an absolute file name under your operating system, Mathematica will search each of the directories specified in the list $Path.
  • If what is found is a directory rather than a file, then Mathematica will look for a file name/$SystemID/name.
  • For names of the form the following further translations are done in Get and related functions:

  • A file is used if it exists.
  • If is a directory, then$SystemID/ is used if it exists.
  • A file name.m is used if it exists.
  • If name is a directory, then the file is used if it exists.
  • In Install, is taken to refer to a file or directory named name.exe.


    InputStream["name",n]input from a file or pipe
    OutputStream["name",n]output to a file or pipe

    Types of streams.

    option name
    default value
    CharacterEncodingAutomaticencoding to use for special characters
    BinaryFormatFalsewhether to treat the file as being in binary format
    FormatTypeInputFormdefault format for expressions
    PageWidth78number of characters per line
    TotalWidthInfinitymaximum number of characters in a single expression

    Options for output streams.

    You can test options for streams using Options, and reset them using SetOptions.

    New to Mathematica? Find your learning path »
    Have a question? Ask support »