接口的使用
java.nio.channels.CompletionHandler
使用 CompletionHandler 的包
-
CompletionHandler 在 java.nio.channels 中的用法
java.nio.channels 中的方法,参数类型为 CompletionHandler修饰符和类型方法描述abstract <A> voidAsynchronousServerSocketChannel.accept(A attachment, CompletionHandler<AsynchronousSocketChannel, ? super A> handler) 接受连接。abstract <A> voidAsynchronousSocketChannel.connect(SocketAddress remote, A attachment, CompletionHandler<Void, ? super A> handler) 连接此通道。abstract <A> voidAsynchronousFileChannel.lock(long position, long size, boolean shared, A attachment, CompletionHandler<FileLock, ? super A> handler) 获取此通道文件的给定区域的锁。final <A> voidAsynchronousFileChannel.lock(A attachment, CompletionHandler<FileLock, ? super A> handler) 获取此通道文件的独占锁。<A> voidAsynchronousByteChannel.read(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) 从此通道读取一系列字节到给定的缓冲区中。abstract <A> voidAsynchronousFileChannel.read(ByteBuffer dst, long position, A attachment, CompletionHandler<Integer, ? super A> handler) 从给定的文件位置开始,从该通道将字节序列读入给定的缓冲区。abstract <A> voidAsynchronousSocketChannel.read(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) 从此通道读取字节序列到给定缓冲区的子序列中。abstract <A> voidAsynchronousSocketChannel.read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) 从此通道读取一系列字节到给定的缓冲区中。final <A> voidAsynchronousSocketChannel.read(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) <A> voidAsynchronousByteChannel.write(ByteBuffer src, A attachment, CompletionHandler<Integer, ? super A> handler) 将给定缓冲区中的字节序列写入此通道。abstract <A> voidAsynchronousFileChannel.write(ByteBuffer src, long position, A attachment, CompletionHandler<Integer, ? super A> handler) 从给定的文件位置开始,从给定的缓冲区向此通道写入一个字节序列。abstract <A> voidAsynchronousSocketChannel.write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) 从给定缓冲区的子序列中将字节序列写入此通道。abstract <A> voidAsynchronousSocketChannel.write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) 将给定缓冲区中的字节序列写入此通道。final <A> voidAsynchronousSocketChannel.write(ByteBuffer src, A attachment, CompletionHandler<Integer, ? super A> handler)