abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r451367 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/ReadWriteByteChannel.java
Date Fri, 29 Sep 2006 18:02:36 GMT
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();
+  }
 }



Mime
View raw message