Read entire file: Difference between revisions
Add Ecstasy example
(Add Ecstasy example) |
|||
Line 687:
The file is assumed to be in the default encoding.
=={{header|Ecstasy}}==
A <span style="background-color: #e5e4e2"><tt> File </tt></span> object in Ecstasy has a <span style="background-color: #e5e4e2"><tt> contents </tt></span> property, which yields a <span style="background-color: #e5e4e2"><tt> Byte[] </tt></span> value:
<syntaxhighlight lang="java">
static Byte[] contentsOf(File file)
{
return file.contents;
}
</syntaxhighlight>
There are also a few ways to obtain the contents of a file at compile-time as a literal instead of reading it at runtime. These examples show how a byte array literal and a string literal can be obtained from two different files, one using a relative path and one using an absolute path:
<syntaxhighlight lang="java">
Byte[] bytes = #./checkmark.ico;
String html = $/docs/website/index.htm;
</syntaxhighlight>
=={{header|Elixir}}==
|