The Artima Developer Community
Sponsored Link

Java Buzz Forum
InputStream vs OutputStream

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
InputStream vs OutputStream Posted: Jan 28, 2015 6:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: InputStream vs OutputStream
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • For each type of source and destination in java.io package oracle given a separate class.
Inputstream vs OutputStream

    InputStream Class:

    • ByteArrayInputStream
    • FileInputStream
    • FilterInputStream
      • BufferedInputStream
      • DataInputStream
      • LineNumberInputStream
      • PushbackInputStream
    • ObjectInputStream
    • PipeInputStream
    • SequenceInputStream
    • StringBufferInputStream

    IputStream Class Methods:

    • Since InputStream class is the super class for all input stream classes. It has below methods with general implementation for all sub classes.

    1.public int available() throws IOException :

    • Checking available bytes to read.

    2.public abstract int read() throws IOException :

    • Reading byte-by-byte.

    3.public int read(byte[] b) throws IOException :

    • Reading all  bytes.

    4.public int read(byte[] b, int off, int length) throws IOException :

    • Reading selected range of bytes.

    5.public boolean markSupported() :

    • Checking is this Stream supports marking.

    6.public void mark(int readLimit) :

    •  Marking current position of stream.

    7.public void reset() throws IOException :

    • Placing the control at marked place.

    8.public long skip(long n) throws IOException :

    • Skip reading given range of bytes.

    9.public void close() throws IOException :

    • Closing the stream.

    OutputStream Class:

    • ByteArrayOutputStream
    • FileOutputStream
    • FilterOutputStream
      • BufferedOutputStream
      • DataOutputStream
      • PrintStream
    • ObjectOutputStream
    • PipeOutputStream

    OutputStream class methods:

    • Since OutputStream is the super class of all binary output stream classes it has below method with general implementation for all sub classes.

    1.public abstract void write(int i)throws IOException:

    • Writing one by at time to an output stream.

    2.public void write(byte[] b) throws IOException :

    • Writing stream of bytes to an output stream.

    3.public void write(byte []b , int off, int length) throws IOException :

    • Writing range of stream of bytes to an output stream.

    4.public void flush() throws IOException :

    • Flush all bytes to destination from output Stream.

    5.public void close() throws IOException :

    • Close output stream.

    FileInputStream and FileOutputStream:

    • These classes are used to read and write data as byte from File.
    • Basically these two streams are used as basic data source and destination for other streams.

    DataInputStream and DataOutputStream:

    • These two classes are used to read and write data as primitive data.
    • Basically these two streams are used to add capability to another input stream and output stream to read and write data as primitive types.

    ObjectInputStream and ObjectOutputStream:

    BufferedInputStream and BufferedOutputStream:

    •  These two classes are used to read and write data as buffers.
    • Basically these two streams are used to improve reading and writing performance of other streams.

    SequenceInputStream:

    • This class is used to read data from multiple InputStreams Sequentially.

     PrintStream: 

    • PrintStream class is filter output stream class .
    • Its adds functionality to another OutputStream, namely the ability to print representations of various data values conveniently.

    Basic steps to perform IO Operations:

    •  Create stream class object based on source and destination.
    • Call read() method to read data from the source.
    • Call write() method to write data to the destination.
    For instance , to perform IO Operations on files we must create
    • FileInputStream
    • FileOutputStream or
    • FileReader
    • FileWriter  Streams class objects.
    -

        Read: InputStream vs OutputStream

        Topic: JDBC DatabaseMetaData Example Previous Topic   Next Topic Topic: Creating JAX-RS web service using RESTEasy Example

        Sponsored Links



        Google
          Web Artima.com   

        Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use