/*
 * Copyright 2010 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package org.jboss.netty.channel;

import java.io.IOException;
import java.nio.channels.WritableByteChannel;

import org.jboss.netty.util.ExternalResourceReleasable;

/**
 * A region of a file that is sent via a {@link Channel} which supports
 * zero-copy file transfer.
 *
 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
 * @author <a href="http://gleamynode.net/">Trustin Lee</a>
 * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
 */
public interface FileRegion extends ExternalResourceReleasable {

    /**
     * Returns the offset in the file where the transfer began.
     */
    long getPosition();

    /**
     * Returns the number of bytes to transfer.
     */
    long getCount();

    /**
     * Transfers the content of this file region to the specified channel.
     */
    long transferTo(WritableByteChannel target) throws IOException;
}
@@ -679,16 +679,54 @@
 eption;%0A
+import java.nio.channels.FileChannel;%0A
 import j
@@ -928,16 +928,1039 @@
 fer.%0A *%0A
+ * %3Ch3%3EUpgrade your JDK / JRE%3C/h3%3E%0A *%0A * %7B@link FileChannel#transferTo(long, long, WritableByteChannel)%7D has at least%0A * four known bugs in the old versions of Sun JDK and perhaps its derived ones.%0A * Please upgrade your JDK to 1.6.0_18 or later version if you are going to use%0A * zero-copy file transfer.%0A * %3Cul%3E%0A * %3Cli%3E%3Ca href=%22http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5103988%22%3E5103988%3C/a%3E%0A *   - FileChannel.transferTo should return -1 for EAGAIN instead throws IOException%3C/li%3E%0A * %3Cli%3E%3Ca href=%22http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6253145%22%3E6253145%3C/a%3E%0A *   - FileChannel.transferTo on Linux fails when going beyond 2GB boundary%3C/li%3E%0A * %3Cli%3E%3Ca href=%22http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6427312%22%3E6427312%3C/a%3E%0A *   - FileChannel.transferTo() throws IOException %22system call interrupted%3C/li%3E%0A * %3Cli%3E%3Ca href=%22http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6524172%22%3E6470086%3C/a%3E%0A *   - FileChannel.transferTo(2147483647, 1, channel) cause %22Value too large%22 exception%3C/li%3E%0A * %3C/ul%3E%0A *%0A
  * @auth

Upgrade your JDK to use FileRegion