// The interleaved data
ByteArrayOutputStream interleaved = new ByteArrayOutputStream();
// Write to interleaved data
InterleavedOutputStream outputStream = new InterleavedOutputStream(
new DataOutputStream(interleaved), metaBlockLength,
dataBlockLength, myMetaDataProducer);
if (writeSize == 0) {
byte[] chunk = new byte[1];
for (int d = 0; d < totalDataLength; d++) {
UtilsForTests.nextBytes(dataRandom, chunk);
outputStream.write(chunk[0] < 0 ? chunk[0] + 256 : (int)chunk[0]);
}
} else {
int written = 0;
while (written < totalDataLength) {
int toWrite = Math.min(writeSize, totalDataLength - written);
byte[] chunk = new byte[toWrite];
UtilsForTests.nextBytes(dataRandom, chunk);
outputStream.write(chunk);
written += toWrite;
}
}
outputStream.close();
// MetaData consumer for the reading
final InterleavedInputStream.MetaDataConsumer myMetaDataConsumer =
new InterleavedInputStream.MetaDataConsumer() {
@Override