fileOpen

Opens a file

fileOpen(filePath [, mode [, charset]]) → returns any

fileOpen Argument Reference

filePath
Required

An absolute path of an on-disk or in-memory file on the server

mode
Default: read

Type of access you require to the file stream
Values:
  • read
  • readBinary
  • write
  • append

charset

Character encoding identified by the file's byte order mark, if any; otherwise, JVM default file character set
Values:
  • utf-8
  • iso-8859-1
  • windows-1252
  • us-ascii
  • shift_jis
  • iso-2022-jp
  • euc-jp
  • euc-kr
  • big5
  • euc-cn
  • utf-16

Examples sample code invoking the fileOpen function

// Open File
var fileObject = fileOpen("/path/to/file.txt");

// Perform Actions
try
{
	// Read Line
	writeOutput(fileReadLine(fileObject));
}

// Error Handling
catch(any ex)
{
	// Report Exception
	writeDump(ex);
}

// Always Close
finally
{
	// Close File
	fileClose(fileObject);
}

Fork me on GitHub