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

/**
 * This class implements a number of UNIX like applications.
 *
 * @author fpereira
 *
 */
public class FileCopier1 {

  /**
   * This method copies the contents of an input file into an output file.
   *
   * @param srcFileName
   *        the name of the file from where data will be read.
   * @param dstFileName
   *        the name of the file into which data will be written.
   * @throws Exception In case something goes wrong.
   */
  public final void cp(final String srcFileName, OutChannel out)
      throws Exception {
    FileInputStream srcFile = new FileInputStream(new File(srcFileName));
    for (int data = srcFile.read(); data >= 0; data = srcFile.read()) {
      out.write(data);
    }
    srcFile.close();
  }

}
