0

I am trying to figure out the best way in which I can write two streams to the same file. The issue that I am trying to solve for is that the top of my file has an XML Header, and then at the bottom I need a comma delimited set of information to be appended.

Is there an easy way to do this in BeanIO? I have already created the xml header but attempting to use the following code block is executing but doing nothing:

BeanWriter xmlHeaderWrite = factory.createWriter(
                          "SendBulkEmailRequest",new   File("xmltest.csv"));
BeanWriter delimRecordsWrite = factory.createWriter(
                          "PipeDelimRecords",new File("xmltest.csv"));
// write an object directly to the BeanWriter
xmlHeaderWrite.write(requestHeader);
delimRecordsWrite.write(customer);
DT7
  • 1,615
  • 14
  • 26
parchambeau
  • 1,141
  • 9
  • 34
  • 56

1 Answers1

2

Rather than passing two File references, you can open a single FileWriter and pass it to both createWriter() calls. Then don't forget to flush and close it yourself.

Kevin
  • 76
  • 1