X937Copier implements X937RecordCopier { @Override public X9Record copy(X9Record input) throws InvalidDataException { X937RecordCopier copier = recordCopiers[input.recordType()]; if (copier == null) { throw new InvalidDataException("Unknown record type" + input.recordType()); } return copier.copy(input); } X937Copier(X9RecordFactory factory); @Override X9Record copy(X9Record input);  }
@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()); }