View source code
Display the source code in std/file.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.file.readText
Read and validates (using std.utf.validate
) a text file. S
can be a type of array of characters of any width and constancy. No
width conversion is performed; if the width of the characters in file
is different from the width of elements of name
S
,
validation will fail.
Prototype
S readText(S)( char[] name ) @safe if (isSomeString!S);
Returns
Array of characters read
.
Throws
on file error, FileException
UTFException
on UTF
decoding error.
Example
enforce(system("echo abc>deleteme") == 0); scope(exit) remove("deleteme"); enforce(chomp(readText("deleteme")) == "abc");
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis