Io stream
Upcoming SlideShare
Loading in...5
×
 

Io stream

on

  • 288 views

 

Statistics

Views

Total Views
288
Views on SlideShare
288
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Io stream Io stream Document Transcript

    • I/O STREAMING<br />STREAM<br />
      • Path of communication between the source of information and the destination
      • 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.
      • Java implements streams within class hierarchies defined in the java.io package.
      • An I/O Stream represents an input source or an output destination
      • All the streams are abstract classes
      • All methods of these classes throws an I/O exception on error conditions
      TYPES OF STREAMS<br />
      • INPUT & OUTPUT STREAMS
      • CHARACTER & BYTE STREAMS
      • FILE & FILTER STREAMS
      • READERS & WRITERS
      • 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
      • 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.
      • 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 />