My ByteArrayOutputStream
contains data for multiple documents (Thus having more that 1 EOF
). While I try to send the output using BufferedOutputStream
, it only passes the data for the last document (probably because it overwrites all other docs but the last one).
Is there any way that I can skip all EOFs except the last one and pass it on to BuffererdOutputStream
?
Java code below:
private void outputBinaryTable(IRecordSet table, BufferedOutputStream output) throws ConnectorException, IOException
{
IRecordMetaData fields = table.retrieveMetaData();
int columnCount = fields.getColumnCount();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//Utils.write("Table " + tableName + " has " + columnCount + " columns.");
loc.errorT("Table Name " + table + " has " + columnCount + " columns.");
if (table.first()){
do // For each row
{
for (int k = 0; k < columnCount; k++)
{
// Get the data as a byte array
byte [] data = table.getBytes(k);
outputStream.write(data);
//Utils.write(new String(data));
// Write the bytes to the output stream
//output.write(data);
}
}
while (table.next());
byte [] combineData = outputStream.toByteArray();
output.write(combineData);
}
}