- Input Stream: These streams carry the data from some source in to the program. The source may be a keyboard, a file …Here read operation is performed to input the data in to the program.
- Output Stream: They carry the data from program to some destination. The destination may be a monitor, printer, a file … Here write operation is performed to send data from the program.
- int read(): Reads next byte from the stream as integer and returns -1 if no data is available in the stream.
- int read(byte b[]): Reads an array full of bytes from the stream and returns actual number of bytes read.
- int read(byte b[], int start, int end): Reads bytes in to array from the specified start and end position form the stream.
- long available(): Returns how many number of bytes yet to be read in the stream.
- long skip(long n): Skips specified number of bytes in the input stream and returns actual number of bytes skipped
- void mark(int readLimit): Marks the current position and it is valid till specified read limit.
- boolean isMarkSupported(): Checks whether the Stream supports the mark facility or not
- void reset(): Moves to the recent marked position or beginning of the stream
- void close(): Closes the stream.
Stream Class Name
|
Use
|
FileInputStream
|
used to read from files
|
PipedInputStream
|
used to read from pipes
|
ByteArrayInputStream
|
used to read from a byte array
|
StringBufferInputStream
|
used to read from a String buffer object
|
ObjectInputStream
|
used to read objects from an input stream
|
SequenceInputStream
|
used to combine two or more input streams
|
BufferedInputStream
|
provides buffer facility to the input stream
|
DataInputStream
|
used to read primitive data from the input stream
|
PushBackInputStream
|
provides un reading facility to the input stream
|
- void write(int b): Writes one byte to output stream.
- void write(byte b[]): Writes an array full of bytes to output stream.
- void write(byte b[], int start, int end): Writes bytes from array to output stream from the specified start and end position.
- void flush(): Flushes the output stream i.e., immediately releases the pending data from stream.
- void close(): Closes the output stream.
Stream
Class Name
|
Use
|
FileOutputStream
|
used to
write data into a file
|
PipedOutputStream
|
used to
write data to a pipe
|
ByteArrayOutputStream
|
used to
write data to a byte array
|
ObjectOutputStream
|
used to
write objects to a output stream
|
BufferedOutputStream
|
provides
buffer facility to the output stream
|
DataOutputStream
|
used to
write primitive data to an input stream
|
zPrintStream
|
Used to
print any data on output stream
|
No comments:
Post a Comment