API for reading and writing files.

See sys.FileSystem for the complementary file system API.

Static methods

@:has_untypedstaticgetContent(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 })staticread(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.

@:has_untyped@:value({ binary : true })staticwrite(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.