Read entire file: Difference between revisions

m
 
(3 intermediate revisions by 2 users not shown)
Line 1,131:
return Files.readAllBytes(file);
}
}</syntaxhighlight>
 
{{works with|Java|11+}}
Java 11 added the method <code>readString</code>:
 
<syntaxhighlight lang="java">
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
 
public class ReadAll {
public static void main(String[] args) {
System.out.print(Files.readString(Path.of(args[0], StandardCharsets.UTF_8)));
}
}</syntaxhighlight>
 
Line 2,053 ⟶ 2,066:
 
=={{header|Standard ML}}==
<syntaxhighlight lang="sml">fun readFile path =
(* string -> string *)
fun readFile path =
(fn strm =>
TextIO.inputAll strm before TextIO.closeIn strm) (TextIO.openIn path)</syntaxhighlight>
</syntaxhighlight>
 
=={{header|Stata}}==
Line 2,256 ⟶ 2,272:
For the following script, a file called "input.txt" has been created which contains the string "abcdefghijklmnopqrstuvwxyz".
<syntaxhighlight lang="ecmascriptwren">import "io" for File
 
System.print(File.read("input.txt"))</syntaxhighlight>
23

edits