}
// Encode data
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
TextEncoder encoder = CharsetTextEncoder.getUTF8();
char[] buffer = new char[256];
for (int l = script.read(buffer); l != -1; l = script.read(buffer)) {
encoder.encode(buffer, 0, l, out);
}
return new ScriptResult.Resolved(out.toByteArray());
} finally {
Safe.close(script);
}