public void writeTo ( OutputStream os , long startPosition , long len ) throws IOException { int segmentSize = 1 << log2OfSegmentSize ; int remainingBytesInSegment = segmentSize - ( int ) ( startPosition & bitmask ) ; long remainingBytesInCopy = len ; while ( remainingBytesInCopy > 0 ) { long bytesToCopyFromSegment = Math . min ( remainingBytesInSegment , remainingBytesInCopy ) ; os . write ( segments [ ( int ) ( startPosition >>> log2OfSegmentSize ) ] , ( int ) ( startPosition & bitmask ) , ( int ) bytesToCopyFromSegment ) ; startPosition += bytesToCopyFromSegment ; remainingBytesInSegment = segmentSize - ( int ) ( startPosition & bitmask ) ; remainingBytesInCopy -= bytesToCopyFromSegment ; } }
Write a portion of this data to an OutputStream .