Spec-Zone.ru › ColdFusion

fileOpen

Opens a file

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

  • CF8+
  • Lucee
  • BL 1.0.0+
  • See Also: fileClose fileCopy fileReadBinary fileRead fileReadLine fileWrite

    Argument Reference

    filePath string
    Required

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

    mode string
    Default: read

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

    charset string

    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

    seekable boolean
    Default: false

    Whether the file is usable with the fileSeek function

    Examples
    Sample code invoking the fileOpen function

    Opens a file, reads a line then closes it.

    // 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);
    }

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/fileopen

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API