Main Content



Check if external file has read attributes

Since R2022b


tf = supportsReading(adapterObj,sourceFile)


tf = supportsReading(adapterObj,sourceFile) checks if the external source file has read attributes. The default implementation uses the isSourceValid method to check that the file exists and is in the correct format, then checks that the file has read attributes. You can override this method so that multiple adapters can read the same file type but with different headers.

Custom file adapters must define behavior for the getAdapterName, getSupportedExtensions, and getData methods. In addition, you can choose to override the isSourceValid, supportsReading, getSectionNames, getCurrentChecksum, open, and close methods.

Input Arguments

expand all

Custom file adapter, specified as an object of a class that derives from the base class.

Example: myCustomFileAdapter

External source file, specified as a character array or string.

Output Arguments

expand all

True or false result, returned as a 1 or 0 of data type logical or an array of logical values.


expand all

Write the function definition for the supportsReading method to determine if the external source file supports reading.

In this example, the supportsReading method reads data from an XML file with a format similar to the following.


The method checks that XML file has read attributes and that it contains the appropriate header information for this adapter.

function retVal = supportsReading(adapterObj, source)
    retVal = false;
    % Call base class method to ensure file has read attributes
        dom = xmlread(source);
        tree = dom.getFirstChild;
        if strcmp(tree.getNodeName, "customerData")
            retVal = true;

Version History

Introduced in R2022b