Low-Level File I/O

Read and write operations at the byte or character level

Functions

fcloseClose one or all open files
feofTest for end of file
ferrorFile I/O error information
fgetlRead line from file, removing newline characters
fgetsRead line from file, keeping newline characters
filereadRead contents of file as text
fopenOpen file, or obtain information about open files
fprintfWrite data to text file
freadRead data from binary file
frewindMove file position indicator to beginning of open file
fscanfRead data from text file
fseekMove to specified position in file
ftellCurrent position
fwriteWrite data to binary file

Examples and How To

Import Text Data Files with Low-Level I/O

Low-level file I/O functions allow the most control over reading or writing data to a file.

Import Binary Data with Low-Level I/O

Low-level file I/O functions allow the most direct control over reading or writing data to a file.

Export to Text Data Files with Low-Level I/O

This example shows how to create text files, including combinations of numeric and character data and nonrectangular files, using the low-level fprintf function.

Export Binary Data with Low-Level I/O

Low-level file I/O functions allow the most direct control over reading or writing data to a file.

Concepts

Methods for Importing Data

MATLAB® import options for various data formats