Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Main {

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

        FileInputStream fin = null;
        FileOutputStream fout = null;

        File file = new File("C:/myfile1.txt");

        fin = new FileInputStream(file);
        fout = new FileOutputStream("C:/myfile2.txt");

        byte[] buffer = new byte[1024];
        int bytesRead;
        while ((bytesRead = fin.read(buffer)) > 0) {
            fout.write(buffer, 0, bytesRead);
        }
        fin.close();
        fout.close();
    }
}