int resourceCount = resources.length;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(out);
dataOut.writeInt(resourceCount);
<BUG>for (int i = 0; i < resources.length; i++) {
writeResource(dataOut, resources[i]);
}</BUG>
dataOut.close();
out.close();

int resourceCount = resources.length;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(out);
dataOut.writeInt(resourceCount);
for (IResource resource : resources) {
writeResource(dataOut, resource);
}
dataOut.close();
out.close();
