io输入输出外文翻译(编辑修改稿)内容摘要:

Java’s I/O picture that you can use it properly. In addition, it’s rather important to understand the evolution of the I/O library, even if your first reaction is Don’t bother me with history, just show me how to use it! The problem is that without the historical perspective, you will rapidly bee confused with some of the classes and when you should and shouldn’t use them. Input and Output Programming language I/O libraries often use the abstraction of a stream, which represents any data source or sink as an object capable of producing or receiving pieces of data. The stream hides the details of what happens to the data inside the 中原工学院信息商务学院毕业设计(论文)译文专用纸 9 actual I/O device. The Java library classes for I/O are divided by input and output, as you can see by looking at the class hierarchy in the JDK documentation. Through inheritance, everything derived from the InputStream or Reader classes has basic methods called read( ) for reading a single byte or an array of bytes. Likewise, everything derived from OutputStream or Writer classes has basic methods called write( ) for writing a single byte or an array of bytes. However, you won’t generally use these methods。 they exist so that other classes can use them— these other classes provide a more useful interface. Thus, you’ll rarely create your stream object by using a single class, but instead will layer multiple objects together to provide your desired functionality (this is the Decorator design pattern, as you shall see in this section). The fact that you create more than one object to produce a single stream is the primary reason that Java’s I/O library is confusing. It’s helpful to categorize the classes by their functionality. In Java , the library designers started by deciding that all classes that had anything to do with input would be inherited from InputStream, and all classes that were associated with output would be inherited from OutputStream. Type of InputStream InputStream’s job is to represent classes that produce input from different sources. These sources can be: 1. An array of bytes. 2. A String obj ect. 3. A file. 4. A pipe, which works like a physical pipe: You put things in at one end and they e out the other. 5. A sequence of other streams, so you can collect them together into a single stream. 中原工学院信息商务学院毕业设计(论文)译文专用纸 10 6. Other sources, such as an Inter connection. Each of these has an associated subclass of InputStream. In addition, the FilterInputStream is also a type of InputStream, to provide a base class for decorator classes that attach attributes or useful interfaces to input streams. Types of OutputStream This category includes the classes that decide where your output will go: an array of bytes (but not a String— presumably, you can create one using the array of bytes), a file, or a pipe. In addition, the FilterOutputStream provides a base class for decorator classes that attach attributes or useful interfaces to output streams. This is discussed later. Adding attributes and useful interfaces Decorators were introduced in the Generics chapter, on page 717. The Java I/O library requires many diff。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。