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

Method main

newio/ChannelCopy.java:13–34  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

11public class ChannelCopy {
12 private static final int BSIZE = 1024;
13 public static void main(String[] args) {
14 if(args.length != 2) {
15 System.out.println(
16 "arguments: sourcefile destfile");
17 System.exit(1);
18 }
19 try(
20 FileChannel in = new FileInputStream(
21 args[0]).getChannel();
22 FileChannel out = new FileOutputStream(
23 args[1]).getChannel()
24 ) {
25 ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
26 while(in.read(buffer) != -1) {
27 buffer.flip(); // Prepare for writing
28 out.write(buffer);
29 buffer.clear(); // Prepare for reading
30 }
31 } catch(IOException e) {
32 throw new RuntimeException(e);
33 }
34 }
35}

Callers

nothing calls this directly

Calls 1

readMethod · 0.45

Tested by

no test coverage detected