package org.academiadecodigo.enuminatti.copyfile;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

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

        String inFilename;
        String outFilename;

        if (args.length < 2) {
            System.out.println("Usage: CopyFile <file1> <file2>");
            inFilename = "resources/testfile.txt";
            outFilename = "resources/out.txt";
        } else {
            inFilename = args[0];
            outFilename = args[1];
        }

        FileIO inFile = new FileIO(inFilename);
        inFile.copyToFile(outFilename);

        try {
            String inFileChecksum = FileIO.getMD5Checksum(inFilename);
            String outFileChecksum = FileIO.getMD5Checksum(outFilename);

            System.out.println(inFilename  + " MD5: " + inFileChecksum);
            System.out.println(outFilename  + " MD5: " + outFileChecksum);

            if (inFileChecksum.equals(outFileChecksum)) {
                System.out.println("Files are identical.");
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }
}
