For Ex: In this I am reading string and int data from the keyboard.
DISDemo.java
DISDemo.java
import java.io.DataInputStream;
import java.io.IOException;
class DISDemo{
public static void main(String arg[] )throws IOException{
DataInputStream dis=new DataInputStream(System.in);
System.out.println("\n\n Enter some STRING data: ");
String s = dis.readLine();
System.out.println("\n\n s: "+s);
System.out.println("\n\n Enter some INTEGER data: ");
int s1 = Integer.parseInt( dis.readLine() );
System.out.println("\n\n s1: "+s1);
}
}
import java.io.IOException;
class DISDemo{
public static void main(String arg[] )throws IOException{
DataInputStream dis=new DataInputStream(System.in);
System.out.println("\n\n Enter some STRING data: ");
String s = dis.readLine();
System.out.println("\n\n s: "+s);
System.out.println("\n\n Enter some INTEGER data: ");
int s1 = Integer.parseInt( dis.readLine() );
System.out.println("\n\n s1: "+s1);
}
}
Output: