W3cubDocs

/Haxe Sys

File

package sys.io

@:coreApi Available on cpp, hl, java, lua, macro, neko, php, python

API for reading and writing to files.

See sys.FileSystem for the complementary file system API.

Static methods

@:has_untyped @:value({ binary : true }) static append (path:String, binary:Bool = true):FileOutput

Similar to sys.io.File.write, but appends to the file if it exists instead of overwriting its contents.

static copy (srcPath:String, dstPath:String):Void

Copies the contents of the file specified by srcPath to the file specified by dstPath.

If the srcPath does not exist or cannot be read, or if the dstPath file cannot be written to, an exception is thrown.

If the file at dstPath exists, its contents are overwritten.

If srcPath or dstPath are null, the result is unspecified.

static getBytes (path:String):Bytes

Retrieves the binary content of the file specified by path.

If the file does not exist or can not be read, an exception is thrown.

sys.FileSystem.exists can be used to check for existence.

If path is null, the result is unspecified.

static getContent (path:String):String

Retrieves the content of the file specified by path as a String.

If the file does not exist or can not be read, an exception is thrown.

sys.FileSystem.exists can be used to check for existence.

If path is null, the result is unspecified.

@:has_untyped @:value({ binary : true }) static read (path:String, binary:Bool = true):FileInput

Returns an FileInput handle to the file specified by path.

If binary is true, the file is opened in binary mode. Otherwise it is opened in non-binary mode.

If the file does not exist or can not be read, an exception is thrown.

Operations on the returned FileInput handle read on the opened file.

File handles should be closed via FileInput.close once the operation is complete.

If path is null, the result is unspecified.

static saveBytes (path:String, bytes:Bytes):Void

Stores bytes in the file specified by path in binary mode.

If the file cannot be written to, an exception is thrown.

If path or bytes are null, the result is unspecified.

static saveContent (path:String, content:String):Void

Stores content in the file specified by path.

If the file cannot be written to, an exception is thrown.

If path or content are null, the result is unspecified.

@:has_untyped @:value({ binary : true }) static write (path:String, binary:Bool = true):FileOutput

Returns an FileOutput handle to the file specified by path.

If binary is true, the file is opened in binary mode. Otherwise it is opened in non-binary mode.

If the file cannot be written to, an exception is thrown.

Operations on the returned FileOutput handle write to the opened file. If the file existed, its previous content is overwritten.

File handles should be closed via FileOutput.close once the operation is complete.

If path is null, the result is unspecified.

© 2005–2018 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/sys/io/File.html