You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2006/09/29 20:02:36 UTC

svn commit: r451367 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java

Author: jmsnell
Date: Fri Sep 29 11:02:35 2006
New Revision: 451367

URL: http://svn.apache.org/viewvc?view=rev&rev=451367
Log:
Add a method for transfering the buffer to another channel (similar to FileChannel.transferto)

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java?view=diff&rev=451367&r1=451366&r2=451367
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java Fri Sep 29 11:02:35 2006
@@ -176,4 +176,11 @@
   private void notflipped() {
     throw new IllegalStateException("The buffer has not yet been flipped");
   }
+  
+  public void transferTo(WritableByteChannel channel) throws IOException {
+    if (!flipped) notflipped();
+    ByteBuffer buf = ByteBuffer.wrap(buffer);
+    while(buf.hasRemaining()) channel.write(buf);
+    buf.clear();
+  }
 }