Jump to content

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>&nbsp;File&nbsp;</tt></span> object in Ecstasy has a <span style="background-color: #e5e4e2"><tt>&nbsp;contents&nbsp;</tt></span> property, which yields a <span style="background-color: #e5e4e2"><tt>&nbsp;Byte[]&nbsp;</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}}==
162

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.