@Test
public void copyTest() throws IOException, InvalidDataException {

    File inFile = new File(x9InputFilename);
    File outFile = new File(x9OutputFilename);
    try (
            X9InputStreamRecordReader reader = new X9InputStreamRecordReader(
                    new FileInputStream(inFile));
            X9OutputStreamRecordWriter writer = new X9OutputStreamRecordWriter(
                    new FileOutputStream(outFile))
    ) {
        RecordCountRecordFilter recordCountRecordFilter = new RecordCountRecordFilter();
        reader.addFilter(recordCountRecordFilter);
        X9RecordFactory factory = new DefaultX9RecordFactoryStrategy()
                .factory(X9RecordFactoryStrategy.X937_STANDARD_DSTU, X9Record.ENCODING_EBCDIC);
        X937Copier copier = new X937Copier(factory);
        for (Record record : reader) {
            writer.write(copier.copy((X9Record) record));
        }
        recordCountRecordFilter.logRecordCounters();
    }
    assertEquals(inFile.length(), outFile.length());
}