directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhe...@apache.org
Subject svn commit: r478046 - /directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java
Date Wed, 22 Nov 2006 06:09:08 GMT
Author: mheath
Date: Tue Nov 21 22:09:07 2006
New Revision: 478046

URL: http://svn.apache.org/viewvc?view=rev&rev=478046
Log:
Updated example.

Modified:
    directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java

Modified: directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java?view=diff&rev=478046&r1=478045&r2=478046
==============================================================================
--- directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java (original)
+++ directory/sandbox/mheath/aio/trunk/src/test/java/AIOTest.java Tue Nov 21 22:09:07 2006
@@ -5,33 +5,24 @@
 import org.apache.aio.AioFutureReadWrite;
 import org.apache.aio.AsynchronousFileChannel;
 
-
 public class AIOTest {
 
 	public static void main(String[] args) throws Exception {
-		FileInputStream in = new FileInputStream("/tmp/foo");
+		FileInputStream in = new FileInputStream("/etc/passwd");
 
 		AsynchronousFileChannel achannel = new AsynchronousFileChannel(in.getFD());
 		
 		
 		AioFutureListener<AioFutureReadWrite> listener = new AioFutureListener<AioFutureReadWrite>()
{
 					public void onCompletion(AioFutureReadWrite ioFuture) {
-						System.out.println("In callback: " + ioFuture.getPosition());
-						System.out.println("  Operation: " + ioFuture.getOperation());
+						System.out.println("In callback");
 						byte[] data = new byte[ioFuture.getBuffer().limit() - ioFuture.getBuffer().position()];
 						ioFuture.getBuffer().get(data);
-						System.out.println("  Buffer: " + new String(data));
-						System.out.println("  Completed: " + ioFuture.isCompleted());
+						System.out.println("  Buffer contains: " + new String(data));
 					}
 				};
 		ByteBuffer buffer = ByteBuffer.allocateDirect(4096);
 		AioFutureReadWrite future = achannel.read(buffer, 0);
-		future.addListener(listener);
-		buffer = ByteBuffer.allocateDirect(4096);
-		future = achannel.read(buffer, 1);
-		future.addListener(listener);
-		buffer = ByteBuffer.allocateDirect(4096);
-		future = achannel.read(buffer, 2);
 		future.addListener(listener);
 		future.join();
 	}



Mime
View raw message