Question:

Program for inputstreamreader in java??

by  |  earlier

0 LIKES UnLike

Program for inputstreamreader in java??

 Tags:

   Report

1 ANSWERS


  1. Hey man ,

    Here is the program for inputstreamreader. Copy,paste & save it as InputStreamDemo.java

    What it will do:

    It will take the input from uesr & displays back. You need to enter any character.

    //**************CODE START  **********************

    import java.io.InputStreamReader;

    /**

    *

    * @author vini_naag2001@yahoo.com.sg

    */

    public class InputStreamDemo {

        

        /** Creates a new instance of InputStreamDemo */

        public InputStreamDemo() {

        }

        

        public static void main(String s[])throws Exception

        {

            System.out.println("Enter A Character:");

            InputStreamReader isr=new InputStreamReader(System.in);

            int userInput=isr.read();

            System.out.println("Entered Character is:"+(char)userInput);

            

        }

    }

    //************ CODE END ***********************

    What i prefer is use DataInputStreamReader instead of InputStreamReader. The advantage is using DataInputStreamReader you can read the line by line instead of char by char;

    for any doubts contact my above mail id..... :)

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions