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

Method main

newio/LargeMappedFiles.java:12–26  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

10public class LargeMappedFiles {
11 static int length = 0x8000000; // 128 MB
12 public static void
13 main(String[] args) throws Exception {
14 try(
15 RandomAccessFile tdat =
16 new RandomAccessFile("test.dat", "rw")
17 ) {
18 MappedByteBuffer out = tdat.getChannel().map(
19 FileChannel.MapMode.READ_WRITE, 0, length);
20 for(int i = 0; i < length; i++)
21 out.put((byte)'x');
22 System.out.println("Finished writing");
23 for(int i = length/2; i < length/2 + 6; i++)
24 System.out.print((char)out.get(i));
25 }
26 }
27}
28/* Output:
29Finished writing

Callers

nothing calls this directly

Calls 3

printMethod · 0.80
getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected