Ballerina API Documentation

Functions of ballerina.lang.files package

function close(File file)

Closes a given file and its stream

Parameters:

Parameter NameData TypeDescription
fileFileThe file to be closed

function copy(File source, File destination)

Copies a file from a given location to another

Parameters:

Parameter NameData TypeDescription
sourceFiletarget: File/Directory that should be copied
destinationFileLocation where the File/Directory should be pasted

function delete(File target)

Deletes a file from a given location

Parameters:

Parameter NameData TypeDescription
targetFileFile/Directory that should be deleted

function exists(File file) (boolean )

Checks whether a file exists

Parameters:

Parameter NameData TypeDescription
fileFileThe File struct of witch existence is to be checked

Return Parameters:

Return VariableData TypeDescription
booleanisExists: Boolean representing whether a file exists

function move(File target, File destination)

Moves a file from a given location to another

Parameters:

Parameter NameData TypeDescription
targetFileFile/Directory that should be moved
destinationFileLocation where the File/Directory should be moved to

function open(File file, string accessMode)

Retrieves the stream from a local file

Parameters:

Parameter NameData TypeDescription
fileFileThe file to be opened
accessModestringfile: The file to be opened

function read(File file, int number) (blob , int )

Retrieves blob value of a file

Parameters:

Parameter NameData TypeDescription
fileFileThe file to be read
numberintNumber of bytes to be read

Return Parameters:

Return VariableData TypeDescription
blobdata: The blob containing files read
intdata: The blob containing files read

function write(blob content, File file)

Writes a file using the given blob

Parameters:

Parameter NameData TypeDescription
contentblobblob: Content to be written
fileFilePath of the file

function writeln(blob content, File file)

Writes a new line to a file using the given blob

Parameters:

Parameter NameData TypeDescription
contentblobblob: Content to be written
fileFilePath of the file


Structs of ballerina.lang.files package

struct File

Fields:

Field NameData TypeDescription
pathstring


Menu

  • Functions
    • close(File file)
    • copy(File source, File destination)
    • delete(File target)
    • exists(File file) (boolean )
    • move(File target, File destination)
    • open(File file, string accessMode)
    • read(File file, int number) (blob , int )
    • write(blob content, File file)
    • writeln(blob content, File file)
  • Structs
    • File

Copyright 2017 Ballerina API Documentation