Mega Code Archive

 
Categories / Java Book / 004 File Stream
 

0239 The Byte Stream Classes

Byte streams are defined by using two class hierarchies. At the top are two abstract classes: InputStream and OutputStream. Stream Class Meaning BufferedInputStream Buffered input stream BufferedOutputStream Buffered output stream ByteArrayInputStream Input stream that reads from a byte array ByteArrayOutputStream Output stream that writes to a byte array DataInputStream An input stream that contains methods for reading the Java standard data types DataOutputStream An output stream that contains methods for writing the Java standard data types FileInputStream Input stream that reads from a file FileOutputStream Output stream that writes to a file FilterInputStream Implements InputStream FilterOutputStream Implements OutputStream InputStream Abstract class that describes stream input ObjectInputStream Input stream for objects ObjectOutputStream Output stream for objects OutputStream Abstract class that describes stream output PipedInputStream Input pipe PipedOutputStream Output pipe PrintStream Output stream that contains print( ) and println( ) PushbackInputStream Input stream that supports one-byte "unget," which returns a byte to the input stream RandomAccessFile Supports random access file I/O SequenceInputStream Input stream that is a combination of two or more input streams that will be read sequentially, one after the other This abstract class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink. Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output. void close() Closes this output stream and releases any system resources associated with this stream. void flush() Flushes this output stream and forces any buffered output bytes to be written out. void write(byte[] b) Writes b.length bytes from the specified byte array to this output stream. void write(byte[] b, int off, int len) Writes len bytes from the specified byte array starting at offset off to this output stream. abstract void write(int b) Writes the specified byte to this output stream. Revised from Open JDK source code