IO优化

 OutputStream os=new FileOutputStream(filePath);

os.write(dataStr);

这种方式昨天测试下来240多万数据大概写了5个小时左右

 

今天做了一下调优,改用FileChannel写入文件,如:

FileChannel os=(new FileOutputStream(filePath)).getChannel();

os.write(StringUtil.getByteBuffer(dataStr));

测试下来大概23分钟就完成了。改动很小,单性能提高了很多。

 

以后有相同写文件需求的可以参考。有兴趣的也可以了解一下FileChannel和nio的其他写文件方式。

 

以下链接可做参考:

http://imp3orc-163-com.iteye.com/blog/890141

posted @ 2016-08-04 17:45  神玄晓  阅读(145)  评论(0编辑  收藏  举报