---
title: "Java append 二进制大文件的几种方法速度比较"
author: "smithfox"
date: "2011-06-09T08:34:43Z"
tags: []
categories: ["编程语言"]
slug: "java-append"
draft: false
lastmod: "2011-06-09T08:34:43Z"
id: 1073755
url: "https://smithfox.iteye.com/blog/1073755"
---

测试环境: Windows7 SP1, 32bit, 4G mem, Intel i5 CPU

 

循环100万次写大约20几个字节, 最终结果:

 

用150K缓存﻿的ByteBuffer和RandomAccessFile写﻿, D:/test2.tmp spent time=177毫秒

用1M缓存﻿的ByteBuffer和RandomAccessFile写, ﻿D:/test3.tmp spent time=177毫秒

用150K的mapsize的MappedByteBuffer写, D:/test4.tmp spent time=320毫秒

用150K缓存﻿的﻿OutputStream写, D:/test5.tmp spent time=610毫秒﻿

 

 

更具体内容详见我个人blog:

 

[http://www.smithfox.com/?e=149](http://www.smithfox.com/?e=149)