# TextResourceFactory

interface TextResourceFactory

Creates `TextResource`s backed by sources such as strings, files, and archive entries.

Example usages:

    def sourcedFromString = resources.text.fromString("some text content")

    def sourcedFromFile = resources.text.fromFile("path/to/file.txt")

    task someTask {} // assumption: produces a text file and declares it as output
    def sourcedFromTask = resources.text.fromFile(someTask)

    def sourcedFromArchiveEntry =
      resources.text.fromArchiveEntry("path/to/archive.zip", "path/to/archive/entry.txt")

    configurations { someConfig } // assumption: contains a single archive
    def sourcedFromConfiguration =
      resources.text.fromArchiveEntry(configurations.someConfig, "path/to/archive/entry.txt")

    def sourceFromUri = resources.text.fromUri("https://example.com/resource")

    def sourceFromInsecureUri = resources.text.fromInsecureUri("http://example.com/resource")

Content copied to clipboard
File based factory methods optionally accept a character encoding. If no encoding is specified, the platform's default encoding is used.

#### Since

2.2

## Functions

fromArchiveEntry
Link copied to clipboard
abstract fun fromArchiveEntry(archive: Any, path: String): TextResource
Same as `fromArchiveEntry(archive, path, Charset.defaultCharset().name())`.
abstract fun fromArchiveEntry(archive: Any, entryPath: String, charset: String): TextResource
Creates a text resource backed by the archive entry at the given path within the given archive.
fromFile
Link copied to clipboard
abstract fun fromFile(file: Any): TextResource
Same as `fromFile(file, Charset.defaultCharset())`.
abstract fun fromFile(file: Any, charset: String): TextResource
Creates a text resource backed by the given file.
fromInsecureUri
Link copied to clipboard
abstract fun fromInsecureUri(uri: Any): TextResource
Creates a text resource backed by the given uri.
fromString
Link copied to clipboard
abstract fun fromString(string: String): TextResource
Creates a text resource backed by the given string.
fromUri
Link copied to clipboard
abstract fun fromUri(uri: Any): TextResource
Creates a text resource backed by the given uri.