MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

files/Writing.java:11–26  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

9 static Random rand = new Random(47);
10 static final int SIZE = 1000;
11 public static void
12 main(String[] args) throws Exception {
13 // Write bytes to a file:
14 byte[] bytes = new byte[SIZE];
15 rand.nextBytes(bytes);
16 Files.write(Paths.get("bytes.dat"), bytes);
17 System.out.println("bytes.dat: " +
18 Files.size(Paths.get("bytes.dat")));
19
20 // Write an iterable to a file:
21 List<String> lines = Files.readAllLines(
22 Paths.get("../streams/Cheese.dat"));
23 Files.write(Paths.get("Cheese.txt"), lines);
24 System.out.println("Cheese.txt: " +
25 Files.size(Paths.get("Cheese.txt")));
26 }
27}
28/* Output:
29bytes.dat: 1000

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected