要写入文本文件的哪个OutputStream子类 [英] Which OutputStream subclass to write to a text file

查看:83
本文介绍了要写入文本文件的哪个OutputStream子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,该程序会将数据输出到.txt文件,使用诸如NotePad之类的程序的人可以读取该文件. 也许不一定是ASCII,而是用户可以理解的内容.

I am writing a program that will output data to a .txt file, that can be read by a person using a program like NotePad. Perhaps not necessarily ASCII, but something that the user can understand.

我要使用其中哪一个?

  • ByteArrayOutputStream
  • FileOutputStream
  • FilterOutputStream
  • ObjectOutputStream
  • OutputStream
  • PipedOutputStream

我有这个作业,要求我专门使用OutputStream子类之一,因此Writer不是一个选择.

I have this assignment that asks me to use one of OutputStream subclasses specifically, so a Writer is not an option.

课程概述

  • ByteArrayOutputStream 直到BalusC给出了更简单的描述之前,我才理解它.显然,它将内容存储在字节数组中,这使它们不可读,因为它们特别是字节.
  • FileOutputStream 它将输出转换为字节,因此也不可读.
  • FilterOutputStream ,我认为它以我不了解的方式转换数据.当您只想在程序中编写内容时就不好用了.
  • ObjectOutputStream ,根据原始数据类型也可以使用DataOutput中的适当方法写入流中.也可以使用writeUTF方法写入字符串."例子提供了答案,但这又使我感到困惑.
  • OutputStream 完全不了解该描述.
  • PipedOutputStream 它创建二进制数据管道.什么是管道?不是一个线索.
  • ByteArrayOutputStream didn't understand it until BalusC gave a more simple description. Apparently it stores things in an array of bytes which makes it unreadable since they are specially bytes.
  • FileOutputStream it makes the output into bytes, so it's also unreadable.
  • FilterOutputStream I think it transform the data in ways I don't understand. Not good when you just want to write things as you write them in the program.
  • ObjectOutputStream according to "Primitive data types can also be written to the stream using the appropriate methods from DataOutput. Strings can also be written using the writeUTF method." and the example provided this might be the answer, but again so much explanation again confuses me.
  • OutputStream Don't understand the description at all.
  • PipedOutputStream It creates pipes of binary data. What are pipes? not a clue.

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆