javaIO简单总结

使用buffer 在外面 速度慢 这里又要分(文件流,字符流,字节流)
使用buffer 在中间 速度快 这里又要分(文件流,字符流,字节流)
没有是使用buffer 速度最慢
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class DataOutputStreamTest {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
long t1 = System.currentTimeMillis();
try {
DataInputStream dos=new DataInputStream(
new BufferedInputStream(new FileInputStream("src/bb.txt"))
);
// BufferedInputStream bufferedInputStream = new BufferedInputStream(
// new DataInputStream(new FileInputStream("src/bb.txt")));
// byte bs[]=new byte[bufferedInputStream.available()];
// bufferedInputStream.read(bs,0,bs.length);
// bufferedInputStream.close();
// System.out.println(new String(bs));///total==14904
// String string = null;
// while ((string = dos.readLine()) != null) {
// System.out.println(string);
// }//total==13812
System.out.println(dos.readUTF());//total==15
dos.close();

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long t2 = System.currentTimeMillis();
System.out.println("total==" + (t2 - t1));

}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值