The Java
The Java
Streams
Sequence of bytes that travel from a source to a destination over a communication path. Streams source-A program which is writing into the stream. Streams destination-A program which is reading from a stream. Two major classes of byte streams 1. InputStream 2.OutputStream
Reader
BufferedReader LineNumberReader CharArrayReader FilterReader PushbackReader InputStreamReader FileReader PipedReader StringReader
Writer
BufferedWriter CharArrayWriter FilterWriter OutputStreamWriter FileWriter PipedWriter PrintWriter StringWriter
File
RandomAccessFile FileDescriptor FilePermission ObjectStreamClass ObjectStreamField SerializablePermission StreamTokenizer
ByteArrayOutputStream Class
It creates an output stream on a byte array. It provide toByteArray() and toString() Methods. It also provide two constructors. The reset() method is used to reset the output buffer. The size() method returns the current number of bytes that have been written to the buffer. The writeTo() method write the contents of the output buffer to the specified output stream. StringBufferInputStream Class It uses StringBuffer to store input data.
File I/O
Java supports stream based file input and output through the File, FileDescriptor, FileInputStream and FileOutputStream Classes. The File Class It is used to access file and directory objects. It provide constructors for creating files and directories. It provide numerous access methods. Directory methods allow directories to be created, deleted, renamed and listed.
The FileOutputStream Class It allows output to be written to a file stream. The SequenceInputStream Class It is used to combine two or more input streams into a single input stream. It does not introduce any new access methods. It provide two constructors.
Filtered I/O
It provide the capability to filter I/O in a number of useful ways. The FilterInputStream Class It provide a capability to create one stream from another. It uses the in variable, which is used to maintain a separate object of class InputStream.
Buffered I/O
When a program reads from the input stream, the input bytes are read from the input buffer. Input buffering is used to speedup overall stream input processing. Output buffering is performed similar manner to input buffering.
PushbackInputStream
It is a filter that push a byte that was previously read back on to the input stream so that it can be reread. It is commonly used with parsers. It allows only a single byte to be pushed back. The pushback character is stored in a variable named pushBack. This class introduces a new method called unread() method.
DataInputStream Class
It provides the capability to read objects and primitive types from an input stream.
readBoolean() readByte() readChar() readDouble() readFloat() readFully() readInt() readLine() readlong()
DataOutputStream Class
It allows arbitrary objects and primitive data to be written to an output stream. It is an output filter and can be combined with any output filtering streams.