Io stream

336 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
336
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Io stream

  1. 1. I/O STREAMING<br />STREAM<br /><ul><li>Path of communication between the source of information and the destination
  2. 2. A stream can represent different kinds of sources and destinations</li></ul>-disk files, devices, other programs, a network socket, and memory arrays<br /><ul><li>Streams support different kinds of data</li></ul>-simple bytes, primitive data types, localized characters and objects<br /><ul><li>Some streams simply pass on data; others manipulate and transform the data in useful ways.
  3. 3. Java implements streams within class hierarchies defined in the java.io package.
  4. 4. An I/O Stream represents an input source or an output destination
  5. 5. All the streams are abstract classes
  6. 6. All methods of these classes throws an I/O exception on error conditions</li></ul>TYPES OF STREAMS<br /><ul><li>INPUT & OUTPUT STREAMS
  7. 7. CHARACTER & BYTE STREAMS
  8. 8. FILE & FILTER STREAMS
  9. 9. READERS & WRITERS
  10. 10. DATA & BUFFERED STREAMS</li></ul>INPUT STREAM<br /><ul><li>A program uses an input stream to read data from a source one item at a time</li></ul>INPUT STREAM - Classes<br /><ul><li>Input streams are used to read data
  11. 11. Java’s basic input class is java.io.InputStream</li></ul>Some of the classes under input stream and their functions:<br />CLASSMEANINGByteArrayInputStreamAllows input stream to read from a byte arrayFileInputStreamAllows input stream to read from a fileFilterInputStreamProvides an interface for useful functionality to other InputStream classes<br />INPUT STREAM – Methods<br /><ul><li>The input stream class provides the fundamental methods needed to read data. </li></ul>The methods in InputStream classes are as follows:<br />1. public int read() throws IOException<br />This method is used to read the data from the buffer.<br />2. public int read(byte[ ] input) throws IOException<br />This method is used to read byte of information. Here byte refers an array of values.<br />3. public int read(byte[ ] input, int offset, int length ) throws IOException<br />This method is used to read byte of information using offset value and length<br />4. public long skip(long ) throws IOException<br />The method is used to skip value or values during read operation.<br />5. public int available() throws IOException<br />This method is used for checking the availability of data during read operation.<br />6. public void close() throws IOException<br />This method is used to close the input stream class.<br />OUTPUT STREAM<br /><ul><li>A program uses an output stream to write data to a destination, one item at time</li></ul>OUTPUT STREAM – Classes<br /><ul><li>Output streams are used to write data.
  12. 12. Java’s basic output class is java.io.OutputStream.</li></ul>CLASSMEANINGByteArrayOutputStreamAllows output stream to write to a byte arrayFileOutputStreamAllows output stream to send to a fileFilterInputStreamProvides an interface for useful functionality to other OutputStream classes<br />OUTPUT STREAM - Methods<br /><ul><li>The public abstract class OutputStream provides the fundamental methods needed to write data. </li></ul>The methods in OutputStream classes are:<br />1. public abstract void write (int ) throws IOException<br />This method is used to write integer values.<br />2. public void write (byte[ ] data) throws IOException<br />This method is used to write data in the form of bytes.<br />3. public void write (byte[ ] data, int offset, int length) throws IOException<br />This method is used to write data from the Offset value in the form of bytes.<br />4. public void flush( ) throws IOException<br />Flush method rescues the user form the deadlock problem<br />5. public void close( ) throws IOException<br />This method is used to close the Output stream class.<br />

×