说出你自己的理解:流(stream)到底是什么?你是怎么理解流(stream)的?

coquettishelf 2004-08-19 04:30:41
据说流(stream)是java语言中受批评最多的部分,而且,流(stream)也确实让很多java新手甚至老手很头疼。你怎么看流(stream)的?你脑中的流(stream)是一个什么样的图景?慷慨的说出来大家共同进步吧!

此处说的流(stream),包含java语言中所有常见的流(stream)。
...全文
675 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
s_help 2004-09-28
  • 打赏
  • 举报
回复
流在使用时应该注意些什么呢?或者说有什么技巧?
Gooing 2004-09-10
  • 打赏
  • 举报
回复
想象一下你前面有一条河
河水里面有nnn多水分子
而水分子都是由0或者1组成的
angelface 2004-09-09
  • 打赏
  • 举报
回复
java的io设计确实有一定的问题
coquettishelf 2004-09-07
  • 打赏
  • 举报
回复
up
usabcd 2004-09-02
  • 打赏
  • 举报
回复
同意 jeffyan77(jeffyan77)
流有多重要?它是Java IO的核心,Java 的IO是Java网络开发的基础,
网络技术是Java的核心,它是几乎所有Java 技术的基础。
包括J2EE/EJB/JMS, Corba, RMI等等.
如果你Java学了很长时间还不熟悉使用流,那么可以说你的Java基础是不扎实的。
虽然Java的IO看起来很烦杂,但是脉络比较清晰,
分字符类和字节类两种。。。。
sylmoon 2004-09-01
  • 打赏
  • 举报
回复
........
bighappy 2004-09-01
  • 打赏
  • 举报
回复
mark一下
jeffyan77 2004-08-30
  • 打赏
  • 举报
回复
Java关于流的概念确实有很多人喜欢,有很多人不喜欢。一般来说,真正读懂了的人比较喜欢。不喜欢的人好像大多数都没有真正搞懂。

很多人认为这是所有语言IO包中设计得最为成功的。我本人基本同意这种观点。
coquettishelf 2004-08-30
  • 打赏
  • 举报
回复
嗯?是这个问题太浅还是太深?怎么没人顶啊?

严博士,支持一下啊
takecare 2004-08-30
  • 打赏
  • 举报
回复
这个看你在什么场景下用了,以下是sun关于io的列表:
Memory
CharArrayReader
CharArrayWriter

ByteArrayInputStream
ByteArrayOutputStream
Use these streams to read from and write to memory. You create these streams on an existing array and then use the read and write methods to read from or write to the array.

StringReader
StringWriter
Use StringReader to read characters from a String in memory. Use StringWriter to write to a String. StringWriter collects the characters written to it in a StringBuffer, which can then be converted to a String.

StringBufferInputStream
StringBufferInputStream is similar to StringReader, except that it reads bytes from a StringBuffer.



Pipe
PipedReader
PipedWriter

PipedInputStream
PipedOutputStream
Implement the input and output components of a pipe. Pipes are used to channel the output from one thread into the input of another. See PipedReader and PipedWriter in action in the section How to Use Pipe Streams.

File
FileReader
FileWriter

FileInputStream
FileOutputStream
Collectively called file streams, these streams are used to read from or write to a file on the native file system. The section How to Use File Streams. has an example that uses FileReader and FileWriter to copy the contents of one file into another.

Concatenation
N/A

SequenceInputStream
Concatenates multiple input streams into one input stream. The section How to Concatenate Files. has a short example of this class.

Object Serialization
N/A

ObjectInputStream
ObjectOutputStream
Used to serialize objects. See Object Serialization.

Data Conversion
N/A

DataInputStream
DataOutputStream
Read or write primitive data types in a machine-independent format. See How to Use DataInputStream and DataOutputStream. shows an example of using these two streams.

Counting
LineNumberReader

LineNumberInputStream
Keeps track of line numbers while reading.

Peeking Ahead
PushbackReader

PushbackInputStream
These input streams each have a pushback buffer. When reading data from a stream, it is sometimes useful to peek at the next few bytes or characters in the stream to decide what to do next.

Printing
PrintWriter

PrintStream
Contain convenient printing methods. These are the easiest streams to write to, so you will often see other writable streams wrapped in one of these.

Buffering
BufferedReader
BufferedWriter

BufferedInputStream
BufferedOutputStream
Buffer data while reading or writing, thereby reducing the number of accesses required on the original data source. Buffered streams are typically more efficient than similar nonbuffered streams and are often used with other streams.

Filtering
FilterReader
FilterWriter

FilterInputStream
FilterOutputStream
These abstract classes define the interface for filter streams, which filter data as it's being read or written. The section Working with Filter Streams shows you how to use filter streams and how to implement your own.

Converting between Bytes and Characters
InputStreamReader
OutputStreamWriter
A reader and writer pair that forms the bridge between byte streams and character streams.
An InputStreamReader reads bytes from an InputStream and converts them to characters, using the default character encoding or a character encoding specified by name.
An OutputStreamWriter converts characters to bytes, using the default character encoding or a character encoding specified by name and then writes those bytes to an OutputStream.
You can get the name of the default character encoding by calling System.getProperty("file.encoding").



详细请参见
http://java.sun.com/docs/books/tutorial/essential/io/datasinks.html
coquettishelf 2004-08-23
  • 打赏
  • 举报
回复
up
draco2002 2004-08-20
  • 打赏
  • 举报
回复
流吗,就是大管子套小管子!

最基本的流就在一个大管子中,我要对它进行操作的话里面就塞个小管子(相当于过滤);

如果还想对过滤出来的流进行操作,就在小管子中塞个小小管子,依次类推,哈
yamakasy 2004-08-20
  • 打赏
  • 举报
回复
Stream对于Unix程序员来说是非常熟悉的东西,在他们看来一点也不蹩脚(开始我也很讨厌这个概念),可以把流看作是数据的一个序列,可以从网络的角度看一下,在这个以数据和网络为中心的时代,流肯定是会一直发展下去的。
coquettishelf 2004-08-20
  • 打赏
  • 举报
回复
呵呵,只要不盲着“流”就行了:)

大家过来说两句吗,好像我在这儿很少见到关于流的讨论。
discolt 2004-08-19
  • 打赏
  • 举报
回复
我是流盲

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧