温少的日志
导航
BlogJava
首页
新随笔
联系
聚合
管理
<
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
统计
随笔 - 70
文章 - 0
评论 - 119
引用 - 0
常用链接
我的随笔
我的评论
我的参与
最新评论
留言簿
(7)
给我留言
查看公开留言
查看私人留言
随笔档案
2008年7月 (1)
2008年6月 (1)
2008年5月 (1)
2008年3月 (1)
2008年2月 (2)
2007年11月 (3)
2007年9月 (3)
2007年5月 (2)
2007年4月 (8)
2007年3月 (6)
2006年11月 (15)
2006年7月 (8)
2006年4月 (1)
2006年3月 (1)
2006年1月 (2)
2005年4月 (1)
2005年3月 (5)
2005年2月 (1)
2005年1月 (2)
2004年12月 (3)
2004年11月 (2)
2004年10月 (1)
链接
温少的日志(主站)
搜索
最新评论
1. re: 一个FileIterator的实现
评论内容较长,点击标题查看
--温少的日志
2. re: 一个FileIterator的实现
评论内容较长,点击标题查看
--kingslee
3. re: 庆祝一下,基于JXTA的P2P文件共享传输文件测试成功。
评论内容较长,点击标题查看
--dfq
4. re: 依然令人失望的Eclipse Software Update功能
呵呵,只关注开发相关功能!
--々上善若水々
5. re: 依然令人失望的Eclipse Software Update功能
eclipse的自动更新是千呼万唤到了3.4才改进了些,
--金迪
阅读排行榜
1. 使用bcel动态创建class(5884)
2. Java aio和JSR 203(4187)
3. JDK 在linux下支持epoll了(3814)
4. 关于java nio在windows下实现(3562)
5. 关于sun JDK nio在linux下的实现。(3221)
评论排行榜
1. 提高编码速度的一个办法(25)
2. JPA这个烂东西(18)
3. 使用JSON替代XML(11)
4. 小议ID生成算法(7)
5. 应用maven的感想(7)
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的实现,十分期待中!!
温少
2007-04-14 12:15
发表评论
posted on 2007-04-14 12:15
温少的日志
阅读(91)
评论(0)
编辑
收藏
新闻频道
新用户注册
刷新评论列表
标题
姓名
主页
验证码
*
内容(请不要发表任何与政治相关的内容)
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
成果网帮您增加网站收入
相关链接:
网站导航:
博客园
BlogJava
博客生活
IT博客网
C++博客
PHP博客
博客园社区
管理博客
教师博客
天文博客
汽车博客
足球博客
股票博客
电子博客
管理