file

fun file(file: File, optional: Boolean = false): Source

Returns a source from specified file.

Format of the file is auto-detected from the file extension. Supported file formats and the corresponding extensions:

  • HOCON: conf

  • JSON: json

  • Properties: properties

  • TOML: toml

  • XML: xml

  • YAML: yml, yaml

Throws UnsupportedExtensionException if the file extension is unsupported.

Return

a source from specified file

Parameters

file

specified file

optional

whether the source is optional

Throws

fun file(file: String, optional: Boolean = false): Source

Returns a source from specified file path.

Format of the file is auto-detected from the file extension. Supported file formats and the corresponding extensions:

  • HOCON: conf

  • JSON: json

  • Properties: properties

  • TOML: toml

  • XML: xml

  • YAML: yml, yaml

Throws UnsupportedExtensionException if the file extension is unsupported.

Return

a source from specified file path

Parameters

file

specified file path

optional

whether the source is optional

Throws