Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class Main {
    public static void main(String[] args) throws Exception {

        FileChannel sourceChannel = new FileInputStream("sourceFile").getChannel();
        FileChannel sinkChannel = new FileOutputStream("newFile").getChannel();

        // Copy source file contents to the sink file
        sourceChannel.transferTo(0, sourceChannel.size(), sinkChannel);
    }
}