温少的日志
我希望我所作的事情对别人有所帮助!
随笔 - 183, 文章 - 1, 评论 - 1139, 引用 - 11
JSR 203终于要出来啦
JSR-000203 More New I/O APIs for the Java Platform - Early Draft Review
http://jcp.org/aboutJava/communityprocess/edr/jsr203/index.html
API的Early Draft Review出来了,就意味很快就要真的出来啦!!
以下是其文档的一个Sample
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);
}
就是我最近很需要的东西,一个异步I/O的实现,十分期待中!!
绿色通道:
好文要顶
关注我
收藏该文
与我联系
posted on 2007-04-14 12:15
温少
阅读(1241)
评论(1)
编辑
收藏
评论
1290567
#1楼
回复
引用
偶然的机会来到此地。是啊,人活着就是要实现自己的价值。谢谢你的资料。
2008-08-18 19:45
|
赵庶娟[未注册用户]
注册用户登录后才能发表评论,请
登录
或
注册
,
返回博客园首页
。
首页
博问
闪存
新闻
园子
招聘
知识库
最新IT新闻
:
·
瑞士公司对苹果提起新专利权诉讼
·
微软看重平板市场:ARM版Win8与x86版同步推
·
多家机构上调LinkedIn目标价 维持买入评级
·
索尼诺基亚卷入裁员潮:危机中竞争更加激烈
·
Google 突袭家庭娱乐领域:为什么说收购摩托罗拉在这里会起作用
»
更多新闻...
最新知识库文章
:
·
高级编程语言的发展历程
·
如何学习一门新的编程语言?
·
学习不同编程语言的重要性
·
为什么我喜欢富于表达性的编程语言
·
计算机专业的女生为什么要学编程
»
更多知识库文章...
China-pub 2011秋季教材巡展
China-Pub 计算机绝版图书按需印刷服务
导航
博客园
首页
新随笔
联系
订阅
管理
<
2007年4月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
公告
昵称:
温少
园龄:
7年7个月
粉丝:
22
关注:
0
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
随笔分类
.NET(35)
(rss)
Java(50)
(rss)
非技术区(14)
(rss)
工作流(4)
(rss)
数据库(18)
(rss)
推荐阅读(25)
(rss)
随笔档案
2010年12月 (1)
2010年7月 (1)
2010年4月 (1)
2009年10月 (1)
2009年9月 (3)
2009年8月 (3)
2009年7月 (1)
2009年4月 (1)
2009年1月 (2)
2008年12月 (1)
2008年9月 (1)
2008年6月 (1)
2008年3月 (1)
2008年2月 (2)
2008年1月 (1)
2007年11月 (6)
2007年10月 (2)
2007年9月 (4)
2007年8月 (1)
2007年6月 (5)
2007年5月 (4)
2007年4月 (13)
2007年3月 (7)
2007年2月 (1)
2007年1月 (1)
2006年11月 (13)
2006年10月 (2)
2006年9月 (3)
2006年8月 (1)
2006年7月 (7)
2006年4月 (3)
2006年3月 (4)
2006年1月 (3)
2005年12月 (3)
2005年7月 (1)
2005年6月 (1)
2005年5月 (2)
2005年4月 (4)
2005年3月 (6)
2005年2月 (1)
2005年1月 (3)
2004年12月 (3)
2004年11月 (2)
2004年10月 (1)
2004年8月 (13)
2004年7月 (53)
文章档案
2004年7月 (1)
相册
生活照片
链接
温少的日志(Java分站)
最新评论
阅读排行榜
评论排行榜
推荐排行榜