Example using DataInputStream

Here we explain the example of a java program using DataInputStream. In this example we take two value a and b from user and calculate the sum of these two number using DataInputStream.
We can see below the java program.

/*Example using DataInputStream.*/
package com.javaforecast4u.io;

      import java.io.DataInputStream;

      public class InputOutput
            public static void main(String[] as)
                        DataInputStream dis = new DataInputStream(System.in);
                        System.out.println("Enter First Number");
                        int a =Integer.parseInt(dis.readLine());
                        System.out.println("Enter Second Number");
                        int b = Integer.parseInt(dis.readLine());
                        int sum = a+b;
                        System.out.println("Sum is "+sum);
                  catch (Exception e)


Enter First Number
Enter Second Number
Sum is 6


  1. Thanks a lot very much for the high quality and results-oriented help.
    I won’t think twice to endorse your blog post to anybody who wants
    and needs support about this area.

    java training in chennai

    java training in bangalore

  2. Ciitnoida provides Core and java training institute in

    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida

  3. Best Summer Internship In Noida

    These technologies prepare individuals for fields like software programming, technical support, graphic design, software testing, business analytics. Embedded Systems, Industrial Automation Training and more. Candidates go through a series of comprehensive practical sessions where they work on live problems and implement solutions on real-time basis.
    It has a dedicated placement cell which provides 100% placement assistance to students. The benefits that a student gets out of summer training are innumerable. CIITN,Best Summer training Center for B.Tech/CS/CSE/IT/ BCA/MCA/ B.E /M.tech / B.sc/ M.sc/ Engineering Student has already accomplished itself successfully in the field of Training and Development after setting milestones and bringing smiles to the faces of more than 1 Lakh students. CIITN was incorporated in the year 2002 and over the years CIITN has grown remarkably into the greatest training giant of Northern India.
    There is no looking back to technology! Those passionate for it need not worry about the professional prospects it offers. Courses and trainings in the field of Computer Science and Applications open a wide array of choices for individuals. All you need to do it prepare yourself right!

    Summer Internship Course In Noida

    Summer Internship Training In Noida

  4. Come & Learn Java from best Java training institute in Ahmedabad and make a successful career with java training institute from Ahmedabad.
    Java training institute in Ahmedabad

  5. Thanks for Sharing a Lovely Post about Software & I must Say it’s really helpful for us & if any want Genuine Experience Certificate in Delhi, Noida and Gurgaon with Complete Verification So Contact us --+91-9599119376 & all Details. More Info here-https://experienceletterindelhi.blogspot.com/