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 comment :

  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