Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Thinking in Java
Prev Contents / Index Next

Types 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 object.
  3. A file.
  4. A “pipe,” which works like a physical pipe: You put things in at one end and they come out the other.
  5. A sequence of other streams, so you can collect them together into a single stream.
  6. Other sources, such as an Internet connection. (This is covered in Thinking in Enterprise Java.)

    Table 12-1. Types of InputStream

    Class

    Function

    Constructor Arguments

    How to use it

    ByteArray-InputStream

    Allows a buffer in memory to be used as an InputStream.

    The buffer from which to extract the bytes.

    As a source of data: Connect it to a FilterInputStream object to provide a useful interface.

    StringBuffer-InputStream

    Converts a String into an InputStream.

    A String. The underlying implementation actually uses a StringBuffer.

    As a source of data: Connect it to a FilterInputStream object to provide a useful interface.

    File-InputStream

    For reading information from a file.

    A String representing the file name, or a File or FileDescriptor object.

    As a source of data: Connect it to a FilterInputStream object to provide a useful interface.

    Piped-InputStream

    Produces the data that’s being written to the associated PipedOutput-Stream. Implements the “piping” concept.

    PipedOutputStream

    As a source of data in multithreading: Connect it to a FilterInputStream object to provide a useful interface.

    Sequence-InputStream

    Converts two or more InputStream objects into a single InputStream.

    Two InputStream objects or an Enumeration for a container of InputStream objects.

    As a source of data: Connect it to a FilterInputStream object to provide a useful interface.

    Filter-InputStream

    Abstract class that is an interface for decorators that provide useful functionality to the other InputStream classes. See Table 12-3.

    See Table 12-3.

    See Table 12-3.

    Thinking in Java
    Prev Contents / Index Next

 
 
   Reproduced courtesy of Bruce Eckel, MindView, Inc. Design by Interspire