File I/O¶
24 built-in function(s) in this category.
Close— Close[stream] (Stable)Export— Export["file", obj] writes obj to a file, choosing the format from the file extension; Export["file", obj, "FMT"] states it explicitly. An Image writes to a raster file (PNG, JPEG, BMP, TGA); its samples outside the unit interval are clamped, since 8-bit output has no room for them. A Graphics object (the result of Plot, ListPlot, Graphics, ...) writes to PDF, PNG, or JPEG: PDF is a resolution-independent vector file produced without any external library and works headless, while PNG and JPEG render through the graphics backend and so need graphics support compiled in and a display. A Graphics3D object (Plot3D, ParametricPlot3D, ...) exports to PNG or JPEG the same way; it has no vector-PDF form. Returns the file name, so Import[Export[f, img]] round-trips. (Stable)FileBaseName— FileBaseName["file"] (Stable)FileExistsQ— FileExistsQ["name"] (Stable)FileExtension— FileExtension["file"] (Stable)FileNameJoin— FileNameJoin[{"name1", "name2", ...}] (Stable)FileNameSplit— FileNameSplit["name"] (Stable)FilePrint— FilePrint["file"] (Stable)FileSize— FileSize["name"] (Stable)Get— Get["filename"] (Stable)Import— Import["file"] reads a raster image file (PNG, JPEG, BMP, GIF, TGA, PSD, HDR, PNM) and returns an Image. Import["file", "Image"] is the same. Samples are scaled by 1/255 into the unit interval, so the result is a "Real" image whatever the file's bit depth, and the file's channel count is preserved -- grey stays 1 channel, RGBA keeps its alpha. Gives $Failed for a missing or malformed file. (Stable)LoadModule— LoadModule["relpath"] (Stable)OpenAppend— OpenAppend["file"] (Stable)OpenRead— OpenRead["file"] (Stable)OpenWrite— OpenWrite["file"] (Stable)Put— Put[expr, "filename"] or expr >> "filename" (Stable)PutAppend— PutAppend[expr, "filename"] or expr >>> "filename" (Stable)Read— Read[stream] (Stable)ReadList— ReadList["file"] (Stable)SetStreamPosition— SetStreamPosition[stream, n] (Stable)StreamPosition— StreamPosition[stream] (Stable)Streams— Streams[] (Stable)Write— Write[stream, expr1, expr2, ...] (Stable)WriteString— WriteString[stream, str1, str2, ...] (Stable)