Functions of ballerina.lang.files package
function close(File file)
Closes a given file and its stream
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
file | File | The file to be closed |
function copy(File source, File destination)
Copies a file from a given location to another
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
source | File | target: File/Directory that should be copied |
destination | File | Location where the File/Directory should be pasted |
function delete(File target)
Deletes a file from a given location
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
target | File | File/Directory that should be deleted |
function exists(File file) (boolean )
Checks whether a file exists
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
file | File | The File struct of witch existence is to be checked |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | isExists: Boolean representing whether a file exists |
function move(File target, File destination)
Moves a file from a given location to another
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
target | File | File/Directory that should be moved |
destination | File | Location where the File/Directory should be moved to |
function open(File file, string accessMode)
Retrieves the stream from a local file
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
file | File | The file to be opened |
accessMode | string | file: The file to be opened |
function read(File file, int number) (blob , int )
Retrieves blob value of a file
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
file | File | The file to be read |
number | int | Number of bytes to be read |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | data: The blob containing files read | |
int | data: The blob containing files read |
function write(blob content, File file)
Writes a file using the given blob
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
content | blob | blob: Content to be written |
file | File | Path of the file |
function writeln(blob content, File file)
Writes a new line to a file using the given blob
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
content | blob | blob: Content to be written |
file | File | Path of the file |
Structs of ballerina.lang.files package
struct File
Fields:
Field Name | Data Type | Description |
---|---|---|
path | string |