JSR 203 is coming soon

Source: Internet
Author: User
JSR-000203 More New I/O APIs for the Java Platform-Early Draft Review

Http://jcp.org/aboutJava/communityprocess/edr/jsr203/index.html

The Early Draft Review of the API is coming out, which means it will come out soon !!

The following is a Sample of the document.

Static class IOTransaction {
Public ByteBuffer buffer (){}
Public long position (){}
Public long updatePosition (int transferred ){}
}

Static class WriteHandler implements CompletionHandler <Integer> {

Public WriteHandler (AsynchronousFileChannel ch ){}

Private AsynchronousFileChannel channel (){}

Public void completed (IoFuture <Integer> result ){
Int bytesTransferred;
Try {
BytesTransferred = result. getNow ();
} Catch (ExecutionException x ){}
 
IOTransaction transaction = (IOTransaction) result. attachment ();
ByteBuffer buffer = transaction. buffer ();
If (buffer. remaining ()> 0 ){
Long position = transaction. updatePosition (bytesTransferred );
Channel (). write (buffer, position, transaction, this );
}
}
}

FileReference file =
List <IOTransaction> transactionList =

AsynchronousFileChannel ch = AsynchronousFileChannel. open (file, OpenFlag. WRITE );

WriteHandler handler = new WriteHandler (ch );

For (IOTransaction transaction: transactionList ){
// Use the transaction as the attachment
Ch. write (transaction. buffer (), transaction. position (), transaction, handler );
}

That's what I need recently. An asynchronous I/O implementation is coming soon !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.