Extensions.File.OpenFileForWrite
Jump to navigation
Jump to search
Contents
Classification
Name | OpenFileForWrite |
Short Description | Opens a File and returns a file handle to this file |
Class | Term |
Extension | OTX File extension |
Group | File related Terms |
Exceptions | FileLockException FileNotFoundException FileOpenException |
Checker Rules | - |
Standard Compliant | Yes |
OTL Syntax
FileWriteHandleTerm File.OpenFileForWrite(StringTerm path, BooleanTerm append, EncodingTerm encoding);
Description
The OpenFileForWrite activity opens a File on the specified path with write access and returns a file handle to this file. If the directory does not exist, the directory and all ancestors shall be created automatically. The file shall be automatically locked to prevent simultaneous reading or writing.
Return Value
The Term returns the value, see table below.
In OTX, Terms are categorized according to its return data type!
Data Type | Description |
FileWriteHandle | Returns a file handle for the file in the specified path. |
Properties
Name | Data Type | Class | Default | Cardinality | Description |
Append | Boolean | Term | - | [0..1] | This parameter is only effective when opening an existing file. If true, the resulting FileWriteHandle will initially contain the original contents of the file. If false, the FileWriteHandle will be created without initial content. If the element is not set, the default value false applies. |
Encoding | Encoding | Term | - | [0..1] | This represents the encoding to be used. The set of standard encodings which shall be supported by any runtime system is given by the Encoding enumeration in StringUtil extension. If the encoding is not specified, it assumes that Strings will be encoded using UTF-8. The encodings HEX, BIN, OCT are not allowed. |
Path | String | Term | - | [1..1] | The file to open. The path parameter is permitted to specify relative or absolute path information. |
OTL Examples
/// Local Declarations
File.FileWriteHandle FileWriteHandle1;
/// Flow
FileWriteHandle1 = File.OpenFileForWrite("file:///D:/abc.txt", false, @Encoding:UTF-8);
See also
CreateTempDirectory
GetFilePath
GetFilesFromDirectory
GetFileSize
IsDirectory
IsEndOfFileReached
IsFile
OpenFileForRead
ReadBytes
ReadFile
ReadLine