//其中能够实现编码的只有OutputStreamWriter和对应inputStreamReader 
package net;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.FileOutputStream; import java.io.*; public class FileIoTest { public static void main(String[] args) throws IOException { FileOutputStream out = null; //只能输出二进制 byte FileOutputStream outSTr = null; BufferedOutputStream Buff = null; FileWriter fw = null; BufferedWriter bf = null; WebContent webcontent =new WebContent(); String url ="http://www.baidu.com/"; String htmlContent = webcontent.getOneHtml(url); int count = 1;// 写文件行数 try {
/****************************采用FileOutputStream方式*************************************************************/
out = new FileOutputStream(new File("D:/FileOutputStream.html")); long begin = System.currentTimeMillis(); for (int i = 0; i < count; i++) { out.write(htmlContent.getBytes()); }
out.close(); long end = System.currentTimeMillis(); System.out.println("FileOutputStream执行耗时:" + (end - begin) + " 豪秒");
/************************************采用BufferedOutputStream方式********************************************************/
outSTr = new FileOutputStream(new File("D:/BufferedOutputStream.html")); Buff = new BufferedOutputStream(outSTr); long begin0 = System.currentTimeMillis(); for (int i = 0; i < count; i++) { Buff.write(htmlContent.getBytes()); } Buff.flush(); Buff.close(); long end0 = System.currentTimeMillis(); System.out.println("BufferedOutputStream执行耗时:" + (end0 - begin0)
+ " 豪秒");
/*********************************采用FileWriter方式**********************************************************/
fw = new FileWriter("D:/FileWriter.html"); long begin3 = System.currentTimeMillis(); for (int i = 0; i < count; i++) { fw.write(htmlContent); } fw.close(); long end3 = System.currentTimeMillis(); System.out.println("FileWriter执行耗时:" + (end3 - begin3) + " 豪秒");
/************************************采用BufferWrite***********************************************************/
OutputStream o1 = new FileOutputStream("D:"+File.separator+"BufferedWriter.html");
OutputStreamWriter fw1 = new OutputStreamWriter(o1,"UTF-8"); bf = new BufferedWriter(fw1); long begin4 = System.currentTimeMillis(); for (int i = 0; i < count; i++) { bf.write(htmlContent); } fw1.flush(); fw1.close(); long end4 = System.currentTimeMillis(); System.out.println("BufferedWriter执行耗时:" + (end4 - begin4) + " 豪秒");
} catch (Exception e) { e.printStackTrace(); } finally { try { fw.close(); Buff.close(); outSTr.close(); out.close(); } catch (Exception e) { e.printStackTrace(); } } } }

io 测试的更多相关文章

  1. 用systemtap对sysbench IO测试结果的分析1

    http://www.actionsky.com/docs/archives/171  2016年5月6日  黄炎 近期在一些简单的sysbench IO测试中, 遇到了一些不合常识的测试结果. 从结 ...

  2. linux 磁盘IO测试工具:FIO (同时简要介绍dd工具测试)

    FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证.磁盘IO是检查磁盘性能的重要指标,可以按照负载情况分成照顺序读写,随机读写两大类. 目前主流的第三方IO测试工具有fio.iomete ...

  3. IO测试工具之fio详解

    目前主流的第三方IO测试工具有fio.iometer和Orion,这三种工具各有千秋. fio在Linux系统下使用比较方便,iometer在window系统下使用比较方便,Orion是oracle的 ...

  4. IO测试工具之fio详解(转)

    http://www.cnblogs.com/raykuan/p/6914748.html 目前主流的第三方IO测试工具有fio.iometer和Orion,这三种工具各有千秋. fio在Linux系 ...

  5. IO测试工具 - 用于IO测试 ; linux benchmarks

    IO测试工具,用于磁盘IO测试,下面进行使用列表进行记录: iozone fio dd ioping iotop iostat bonnie++ crystalDisk Atto as-ssd-ben ...

  6. 91云服务器网络带宽测试,IO测试、全国ping测试

    91yun服务器测试一键包介绍 一键包主要是为了让大家快速对服务器的基本状况有一个了解.考虑到天朝的网络出口问题,所以这个一键包更加偏向网络的测试. 影响测试耗时主要是下载,整个测试如果是能跑满100 ...

  7. Linxu IO测试软件

    fio 安装 apt-get install fio fdisk -l Device Boot Start End Blocks Id System/dev/sda1 * 2048 968390655 ...

  8. ---dd io测试

    下面是一个简单测试,虽然不够准确但是简单立即可行, 当前目录的IO写读测试: (写) dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync ( ...

  9. mongodb的IO测试工具 mongoperf

    之前没发现mongoperf这个工具,测试IO的状态用的是iostat来进行观察. mongoperf < myjsonconfigfile  echo "{nThreads:2,fi ...

随机推荐

  1. 4.I/O复用以及基于I/O复用的回射客户端/服务器

    I/O复用:当一个或多个I/O条件满足时,我们就被通知到,这种能力被称为I/O复用. 1.I/O复用的相关系统调用 posix的实现提供了select.poll.epoll两类系统调用以及相关的函数来 ...

  2. VS Code开发调试ASP.NET Core 1.0

    VS Code开发调试ASP.NET Core 1.0 使用VS Code开发调试ASP.NET Core 1.0,微软在今天凌晨发布了.NET Core 1.0,ASP.NET Core 1.0 与 ...

  3. 集合如何判断null

    转http://blog.csdn.net/baple/article/details/8604585 java判断list为空 分类: JAVA 2013-02-23 08:47 18368人阅读 ...

  4. linux下java窗口,正确显示中文

    Tip1 1.在 JAVA_HOME/jre/lib/fonts/ 下建立个目录 fallback 2.在 fallback 里弄个中文字体最简单ln一下就好了 比如: ln -s /usr/shar ...

  5. 基于visual Studio2013解决C语言竞赛题之0602最大值函数

     题目

  6. UVA 10020 Minimal coverage(贪心 + 区间覆盖问题)

     Minimal coverage  The Problem Given several segments of line (int the X axis) with coordinates [Li, ...

  7. LTP介绍

    1.LTP介绍    LTP--linut test project ,ltp套件是由Linux Test Project所开发的一套系统測试套件.它基于系统资源的利用率统计开发了一个測试的组合,为系 ...

  8. HDU 1432 Lining Up (POJ 1118)

    枚举,枚举点 复杂度为n^3. 还能够枚举边的,n*n*log(n). POJ 1118 要推断0退出. #include<cstdio> #include<cstring> ...

  9. 如何实现android蓝牙开发 自动配对连接,并不弹出提示框

    之前做一个android版的蓝牙 与血压计通讯的项目,遇到最大的难题就是自动配对. 上网查资料说是用反射createBond()和setPin(),但测试时进行配对还是会出现提示,但配对是成功了 我就 ...

  10. 【BZOJ1132】【POI2008】Tro 计算几何 叉积求面积

    链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...