import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class FileCopier {

    /**
     * Creates a copy of a file to a specified location.
     * <p>
     * Requires: file is small enough to fit into memory at once.
     *
     * @param src Input file path
     * @param dest Output file path
     * @throws IOException if file paths could not be found, read, written to, or anything
     * else goes wrong when copying the file
     */
    public static void copyFile(String src, String dest) throws IOException {
        try (InputStream in = new FileInputStream(src)) {
            try (OutputStream out = new FileOutputStream(dest)) {
                out.write(in.readAllBytes());
            }
        }
    }
}
