Your SlideShare is downloading. ×
Io stream
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Io stream

189
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
189
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. I/O STREAMING<br />STREAM<br />
    • Path of communication between the source of information and the destination
    • 2. A stream can represent different kinds of sources and destinations
    -disk files, devices, other programs, a network socket, and memory arrays<br />
    • Streams support different kinds of data
    -simple bytes, primitive data types, localized characters and objects<br />
    • Some streams simply pass on data; others manipulate and transform the data in useful ways.
    • 3. Java implements streams within class hierarchies defined in the java.io package.
    • 4. An I/O Stream represents an input source or an output destination
    • 5. All the streams are abstract classes
    • 6. All methods of these classes throws an I/O exception on error conditions
    TYPES OF STREAMS<br />
    • INPUT & OUTPUT STREAMS
    • 7. CHARACTER & BYTE STREAMS
    • 8. FILE & FILTER STREAMS
    • 9. READERS & WRITERS
    • 10. DATA & BUFFERED STREAMS
    INPUT STREAM<br />
    • A program uses an input stream to read data from a source one item at a time
    INPUT STREAM - Classes<br />
    • Input streams are used to read data
    • 11. Java’s basic input class is java.io.InputStream
    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 />
    • The input stream class provides the fundamental methods needed to read data.
    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 />
    • A program uses an output stream to write data to a destination, one item at time
    OUTPUT STREAM – Classes<br />
    • Output streams are used to write data.
    • 12. Java’s basic output class is java.io.OutputStream.
    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 />
    • The public abstract class OutputStream provides the fundamental methods needed to write data.
    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 />