import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
os.write(buf, 0, readBytes);
}
+ // Pad to the end of the block with -1s
+ int usedInBlock = length % _block_size;
+ if (usedInBlock != 0 && usedInBlock != _block_size) {
+ int toBlockEnd = _block_size - usedInBlock;
+ byte[] padding = new byte[toBlockEnd];
+ Arrays.fill(padding, (byte)0xFF);
+ os.write(padding);
+ }
+
// Tidy and return the length
os.close();
return length;
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3)); // Mini
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(4));
+ // First 2 Mini blocks will be used
assertEquals(2, ministore.getFreeBlock());
// Add one more mini-stream, and check
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(3)); // Mini
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(4));
+ // One more mini-block will be used
assertEquals(3, ministore.getFreeBlock());
// Check the contents too