TextResource

API Documentation:TextResource

A read-only body of text backed by a string, file, archive entry, or other source. To create a text resource, use one of the factory methods in TextResourceFactory (e.g. project.resources.text.fromFile(myFile)).

Properties

PropertyDescription
buildDependencies

Returns a dependency which contains the tasks which build this artifact. All Buildable implementations must ensure that the returned dependency object is live, so that it tracks changes to the dependencies of this buildable.

Methods

MethodDescription
asFile()

Same as asFile(Charset.defaultCharset().name()).

asFile(charset)

Returns a file containing the resource's text and using the given character encoding. If this resource is backed by a file with a matching encoding, that file may be returned. Otherwise, a temporary file will be created and returned.

asReader()

Returns an unbuffered Reader that allows the resource's text to be read. The caller is responsible for closing the reader.

asString()

Returns a string containing the resource's text

Script blocks

No script blocks

Property details

TaskDependency buildDependencies (read-only)

Returns a dependency which contains the tasks which build this artifact. All Buildable implementations must ensure that the returned dependency object is live, so that it tracks changes to the dependencies of this buildable.

Method details

File asFile()

Same as asFile(Charset.defaultCharset().name()).

File asFile(String charset)

Returns a file containing the resource's text and using the given character encoding. If this resource is backed by a file with a matching encoding, that file may be returned. Otherwise, a temporary file will be created and returned.

Reader asReader()

Returns an unbuffered Reader that allows the resource's text to be read. The caller is responsible for closing the reader.

String asString()

Returns a string containing the resource's text