免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2380 | 回复: 1
打印 上一主题 下一主题

JAVA IO 的几个基本概念 ,need help [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-20 10:39 |只看该作者 |倒序浏览
What is meant by?

  1. new BufferedInputStream(
  2. new FileInputStream("filename")));
复制代码


and


  1. new DataInputStream(
  2. new BufferedInputStream(
  3. new FileInputStream("filename")));
复制代码


then


  1. new BufferedReader(
  2. new DataInputStream(
  3. new BufferedInputStream(
  4. new FileInputStream("filename"))));
复制代码

论坛徽章:
0
2 [报告]
发表于 2007-03-20 15:03 |只看该作者
为打开一个文件以便输入,需要使用一个FileInputStream,同时将一个String或File对象作为文件名使用。为提高速度,最好先对文件进行缓冲处理,从而获得用于一个BufferedInputStream的构建器的结果句柄。为了以格式化的形式读取输入数据,我们将那个结果句柄赋给用于一个DataInputStream的构建器。如果要使用readLine(),那时需要使用一个BufferedReader。
DataInputStream中的readLine()方法是被Deprecated的,可以参看jdk文档中的描述:
readLine()
          Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
     DataInputStream d = new DataInputStream(in);
with:
     BufferedReader d
          = new BufferedReader(new InputStreamReader(in));
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP