Source Code : Comparing Buffered and Unbuffered Writing Performance
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Comparing Buffered and Unbuffered Writing Performance
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
public class BufferDiff {
public static void main(String args[]) throws IOException {
FileOutputStream unbufStream;
BufferedOutputStream bufStream;
unbufStream = new FileOutputStream("test.one");
bufStream = new BufferedOutputStream(new FileOutputStream("test.two"));
System.out.println("Write file unbuffered: " + time(unbufStream) + "ms");
System.out.println("Write file buffered: " + time(bufStream) + "ms");
}
static int time(OutputStream os) throws IOException {
Date then = new Date();
for (int i = 0; i < 500000; i++) {
os.write(1);
}
os.close();
return (int) ((new Date()).getTime() - then.getTime());
}
}
Thank with us