.readFile()

Method to read the contents of a file. The method returns the content of the file. Line feeds are preserved. You can also use the method .content().

This method was originally created by Adobe.

Note: Do not confuse this method with the default ExtendScript method read().

The method .readFile() is located in the file file.jsxinc.

Usage

var file = new File("C:/myfile.txt");
var filecontents = file.readFile();

Parameters

Paramter Data type Required Description
encoding String   The file encoding used for reading the file.

Return values

Value Meaning
null The file does not exist.
string The contents of the file.