pos = raf.length();
}
else
if (out instanceof SeekableByteArrayOutputStream)
{
SeekableByteArrayOutputStream sbaos = (SeekableByteArrayOutputStream)out;
pos = sbaos.getPosition();
}
long compressedSize = pos - compressedDataOffset;
compressedSize = Math.min(0xffff, compressedSize);
/*
System.out.println("compressed data offset=" + compressedDataOffset);
System.out.println("position after compression=" + pos);
System.out.println("compressed size=" + compressedSize + " / " + Integer.toHexString((int)compressedSize));
*/
if (out instanceof RandomAccessFile)
{
RandomAccessFile raf = (RandomAccessFile)out;
raf.seek(compressedDataOffset);
raf.writeShort((int)compressedSize);
}
else
if (out instanceof SeekableByteArrayOutputStream)
{
SeekableByteArrayOutputStream sbaos = (SeekableByteArrayOutputStream)out;
sbaos.seek((int)compressedDataOffset);
sbaos.write((int)(compressedSize >> 8) & 0xff);
sbaos.write((int)compressedSize & 0xff);
}
}