
hiiiii... get input different different type like as DataInputStream,Scanner i want to get source code of these all type of input method. thank

Java Read through DataInputStream:
import java.io.*;
class ReadFromDataInputStream{
public static void main(String[] args) throws Exception{
DataInputStream in = new DataInputStream(System.in);
System.out.println("Enter Name: ");
String name=in.readLine();
System.out.println("Name is: "+name);
}
}

Java read input through Scanner:
import java.util.*;
class ScannerExample
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter integer: ");
int i=input.nextInt();
System.out.print("Enter double: ");
double d=input.nextDouble();
System.out.print("Enter float: ");
float f=input.nextFloat();
System.out.print("Enter string: ");
String s=input.next();
System.out.println(i);
System.out.println(d);
System.out.println(f);
System.out.println(s);
}
}

Java read input through BufferedReader
import java.io.*;
public class ReadFromBufferedReader {
public static void main(String[] args)throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Name: ");
String input = reader.readLine();
System.out.println("Name is: "+name);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.