private void writeToImpl(Writer out, long writeStart, long writeEnd) throws IOException {
    """
	Implementation of writeTo
	
	@param out
	@param writeStart  The absolute index to write from
	@param writeEnd    The absolute index one past last character to write
	@throws IOException
    """
		try ( // TODO: If copying to another SegmentedBufferedWriter or AutoTempFileWriter, we have a chance here for disk-to-disk block level copying instead of going through all the conversions.
			RandomAccessFile raf = new RandomAccessFile(tempFile.getFile(), "r")) {
			byte[] bytes = BufferManager.getBytes();
			try {
				char[] chars = BufferManager.getChars();
				try {
					long index = writeStart;
					raf.seek(index<<1);
					while(index<writeEnd) {
						// Read a block
						long blockSizeLong = (writeEnd - index)<<1;
						int blockSize = blockSizeLong > BufferManager.BUFFER_SIZE ? BufferManager.BUFFER_SIZE : (int)blockSizeLong;
						assert (blockSize&1) == 0 : "Must be an even number for UTF-16 conversion";
						raf.readFully(bytes, 0, blockSize);
						// Convert to characters
						for(
							int bpos=0, cpos=0;
							bpos<blockSize;
							bpos+=2, cpos++
						) {
							chars[cpos] = IoUtils.bufferToChar(bytes, bpos);
						}
						// Write to output
						out.write(chars, 0, blockSize>>1);
						// Update location
						index += blockSize>>1;
					}
				} finally {
					BufferManager.release(chars, false);
				}
			} finally {
				BufferManager.release(bytes, false);
			}
		}
	}
private void writeToImpl(Writer out, long writeStart, long writeEnd) throws IOException {
		try ( // TODO: If copying to another SegmentedBufferedWriter or AutoTempFileWriter, we have a chance here for disk-to-disk block level copying instead of going through all the conversions.
			RandomAccessFile raf = new RandomAccessFile(tempFile.getFile(), "r")) {
			byte[] bytes = BufferManager.getBytes();
			try {
				char[] chars = BufferManager.getChars();
				try {
					long index = writeStart;
					raf.seek(index<<1);
					while(index<writeEnd) {
						// Read a block
						long blockSizeLong = (writeEnd - index)<<1;
						int blockSize = blockSizeLong > BufferManager.BUFFER_SIZE ? BufferManager.BUFFER_SIZE : (int)blockSizeLong;
						assert (blockSize&1) == 0 : "Must be an even number for UTF-16 conversion";
						raf.readFully(bytes, 0, blockSize);
						// Convert to characters
						for(
							int bpos=0, cpos=0;
							bpos<blockSize;
							bpos+=2, cpos++
						) {
							chars[cpos] = IoUtils.bufferToChar(bytes, bpos);
						}
						// Write to output
						out.write(chars, 0, blockSize>>1);
						// Update location
						index += blockSize>>1;
					}
				} finally {
					BufferManager.release(chars, false);
				}
			} finally {
				BufferManager.release(bytes, false);
			}
		}
	}
private void writeToImpl ( Writer out , long writeStart , long writeEnd ) throws IOException { try ( // TODO: If copying to another SegmentedBufferedWriter or AutoTempFileWriter, we have a chance here for disk-to-disk block level copying instead of going through all the conversions. RandomAccessFile raf = new RandomAccessFile ( tempFile . getFile ( ) , "r" ) ) { byte [ ] bytes = BufferManager . getBytes ( ) ; try { char [ ] chars = BufferManager . getChars ( ) ; try { long index = writeStart ; raf . seek ( index << 1 ) ; while ( index < writeEnd ) { // Read a block long blockSizeLong = ( writeEnd - index ) << 1 ; int blockSize = blockSizeLong > BufferManager . BUFFER_SIZE ? BufferManager . BUFFER_SIZE : ( int ) blockSizeLong ; assert ( blockSize & 1 ) == 0 : "Must be an even number for UTF-16 conversion" ; raf . readFully ( bytes , 0 , blockSize ) ; // Convert to characters for ( int bpos = 0 , cpos = 0 ; bpos < blockSize ; bpos += 2 , cpos ++ ) { chars [ cpos ] = IoUtils . bufferToChar ( bytes , bpos ) ; } // Write to output out . write ( chars , 0 , blockSize >> 1 ) ; // Update location index += blockSize >> 1 ; } } finally { BufferManager . release ( chars , false ) ; } } finally { BufferManager . release ( bytes , false ) ; } } }
Implementation of writeTo

@param out
@param writeStart  The absolute index to write from
@param writeEnd    The absolute index one past last character to write
@throws IOException
Implementation of writeTo