Read entire file: Difference between revisions

(→‎Java: OK, I got around to writing a correct version)
Line 108:
<lang clojure>(slurp "myfile.txt")
(slurp "my-utf8-file.txt" "UTF-8")</lang>
 
 
=={{header|D}}==
D version 2. To read a whole file into a dynamic array of unsigned bytes:
<lang d>import std.file: read;
 
void main() {
auto data = cast(ubyte[])read("data.raw");
}</lang>
To read a whole file into a validated UTF-8 string:
<lang d>import std.file: readText;
 
void main() {
string s = readText("text.txt");
}</lang>
 
=={{header|E}}==
Anonymous user