EncodedResource class final

A resource paired with the character encoding to read it in; null means UTF-8.

It carries @PropertySource(encoding: ...) to the PropertySourceFactory, which is where applications meet it: a custom factory reads the file through it, so the declared encoding is used.

// A legacy file in ISO-8859-1.
final resource = EncodedResource(
  FileSystemResource('config/legacy.properties'),
  encoding: latin1,
);
resource.readAsStringSync();

Spring (Java):

var resource = new EncodedResource(
    new FileSystemResource("config/legacy.properties"),
    StandardCharsets.ISO_8859_1);

Constructors

EncodedResource(Resource resource, {Encoding? encoding})
Pairs resource with the encoding to read it in (UTF-8 when null).
const

Properties

encoding → Encoding?
The declared encoding, or null for UTF-8.
final
hashCode → int
The hash code for this object.
no setteroverride
resource → Resource
The resource to read.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAsString() → Future<String>
Reads the whole content as text, decoded with encoding.
readAsStringSync() → String
Reads the whole content as text without waiting, decoded with encoding. Throws UnsupportedError when the resource cannot be read synchronously.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override