File

private class
system.platform.File

Description

The File class provides many common file operations for text and binary files.

API overview

Constructor

File ()

Functions

Public functions

copy ( pathSource: String , pathDestination: String ): Boolean static

Copies a file from pathSource to pathDestination

Please note that this implementation requires the file be loaded into memory

fileExists ( path: String ): Boolean static

Checks whether a file exists at the given path

loadBinaryFile ( path: String ): ByteArray static

Loads a binary file at the given path

loadTextFile ( path: String ): String static

Loads a text file at the given path

removeFile ( path: String ): Boolean static

Removes a file at the given path

writeBinaryFile ( path: String , data: ByteArray ): Boolean static

Writes a binary file at the given path

writeTextFile ( path: String , text: String ): Boolean static

Writes a text file at the given path

Constructor

File ()

Functions

copy ( pathSource: String , pathDestination: String ): Boolean

static

Copies a file from pathSource to pathDestination

Please note that this implementation requires the file be loaded into memory. Therefore, it must fit into available memory.

Parameters

pathSource: String the source file to copy
pathDestination: String the destination file to write

Returns

Boolean true on success, false on failure.

fileExists ( path: String ): Boolean

static

Checks whether a file exists at the given path.

@result true if the file exists, false if it doesn't.

Parameters

path: String the full path to the file to check.


getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

loadBinaryFile ( path: String ): ByteArray

static

Loads a binary file at the given path.

Parameters

path: String the full path to the binary file to load.

Returns

ByteArray a ByteArray with the contents of the binary file or null if the file can't be loaded.

loadTextFile ( path: String ): String

static

Loads a text file at the given path.

Parameters

path: String the full path to the text file to load.

Returns

String a string with the contents of the text file or null if the file can't be loaded.

removeFile ( path: String ): Boolean

static

Removes a file at the given path.

@result true on success, false on failure.

Parameters

path: String the full path to the file to remove.


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

writeBinaryFile ( path: String , data: ByteArray ): Boolean

static

Writes a binary file at the given path.

Parameters

path: String the full path to the binary file to load.
data: ByteArray the ByteArray which contains the data to write to the file.

Returns

Boolean true on success, false on failure.

writeTextFile ( path: String , text: String ): Boolean

static

Writes a text file at the given path.

Parameters

path: String the full path to the binary file to load.
text: String the text to write to the file.

Returns

Boolean true on success, false on failure.