KADABRA API

LARA API

LARA Common Language API

Io

Io

Io

Utility methods related with input/output operations on files.


Static Members

appendFile

appendFile(path, content)

Parameters

path: any
content: any

copyFile

copyFile(filepath, destination)

Parameters

filepath: any
destination: any

copyFolder

copyFolder(filepath, destination, verbose)

Parameters

filepath: any
destination: any
verbose: any

deleteFile

deleteFile(fileOrBaseFolder, optionalFile)

Deletes the given file.

Parameters

fileOrBaseFolder: any
optionalFile: any

deleteFiles

deleteFiles()

Each argument is a file that will be deleted.


deleteFolder

deleteFolder(folderPath)

Deletes a folder and its contents.

Parameters

folderPath: any

Returns

any - true if both the contents and the folder could be deleted

deleteFolderContents

deleteFolderContents(folderPath)

Deletes the contents of a folder.

Parameters

folderPath: any

getAbsolutePath

getAbsolutePath(fileOrBaseFolder, optionalFile)

Parameters

fileOrBaseFolder: any
optionalFile: any

Returns

String - the absolute path of the given file

getExtension

getExtension(path)

Returns the extension of the given path.

Parameters

path: string|#java.io.File

getFiles

getFiles(baseFolder, pattern, isRecursive)

The files inside the given folder that respects the given pattern.

Parameters

baseFolder: string|File
pattern: string|Object[]
isRecursive: boolean

getFolders

getFolders(baseFolder, patterns)

Gets the folders in the given folder, corresponding to the given base folder and argument patterns.

Parameters

baseFolder: String|J#java.io.File
patterns: String...

getPath

getPath(fileOrBaseFolder, optionalFile)

Parameters

fileOrBaseFolder: any
optionalFile: any

getPathSeparator

getPathSeparator()

The system-dependent path-separator (e.g., : or ;).


getPaths

getPaths(baseFolder, patterns)

Gets the paths (files and folders) in the given folder, corresponding to the given base folder and argument patterns.

Parameters

baseFolder: String|J#java.io.File
patterns: String...

getRelativePath

getRelativePath(targetFile, baseFile)

Returns the path of 'targetFile', relative to 'baseFile'.

If the file does not share a common ancestor with baseFile, returns undefined.

Parameters

targetFile: any
baseFile: any

getSeparator

getSeparator()

The system-dependent name-separator (e.g., / or \).


getTempFolder

getTempFolder(folderName)

If folderName is undefined, returns the OS temporary folder.
If defined, creates a new folder inside the system's temporary folder and returns it.

Parameters

folderName: any

getWorkingFolder

getWorkingFolder()

isFile

isFile(path)

Parameters

path: any

Returns

any - true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise

isFolder

isFolder(path)

Parameters

path: any

Returns

any - true if and only if the file denoted by this abstract pathname exists and is a folder; false otherwise

isJavaFile

isJavaFile(object)

Parameters

object: any

Returns

boolean - true if the given object is a Java file, false otherwise.

jsonObject

jsonObject(value)

If value is a string that ends in .json, assume it is a file to a json object and parses it.
If it is a string but does not end in json, assume it is a stringified object.
Otherwise, returns the object as it is.

Parameters

value: any

md5

md5(fileOrBaseFolder, optionalFile)

Parameters

fileOrBaseFolder: any
optionalFile: any

mkdir

mkdir(fileOrBaseFolder, optionalFile)

Creates a folder.

Parameters

fileOrBaseFolder: any
optionalFile: any

newRandomFolder

newRandomFolder()

Creates a randomly named folder in the OS temporary folder that is deleted when the virtual machine exits.

Returns

J#java.io.File

readFile

readFile(path)

Parameters

path: string - The path of the file to read.

Returns

string - the contents of the file.

readJson

readJson(path)

Parameters

path: any

readLines(fileOrBaseFolder, optionalFile)

Returns a List with a string for each line of the given file

Parameters

fileOrBaseFolder: any
optionalFile: any

removeExtension

removeExtension(path)

Returns the given path, without extension.

Parameters

path: string|#java.io.File

writeFile

writeFile(path, content)

Parameters

path: string - The path of the file to write.
content: string - The contents to write.

Returns

J#java.io.File - the file to where the contents where written.

writeJson

writeJson(path, object)

Parameters

path: any
object: any

Global Functions

deleteFile

deleteFile(fileOrBaseFolder, optionalFile)

Global version of the function.

Parameters

fileOrBaseFolder: any
optionalFile: any

mkdir

mkdir(fileOrBaseFolder, optionalFile)

Global version of the function.

Parameters

fileOrBaseFolder: any
optionalFile: any

readLines

readLines(fileOrBaseFolder, optionalFile)

Global version of the function.

Parameters

fileOrBaseFolder: any
optionalFile: any