Hi,
I'm writing Java program to map two files.How can string input be given in Java?
Thanks in advance.
ehm ...
JOptionPane, Scanner, a Swing GUI, command line parameters, properties files, xml files, ...
this is a bit like asking "how many different beers are there in the world?"
basically, a lot, and everybody can come up with and write new ways, so it's not really possible to sum them all up, allthough most ways will use one of those I mentioned above.
Thank u. I used command line.
The following example worked for me:
import java.io.*;
class StringInputEx{
public static void main(String args[]){
BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a name:");
String name=null;
try {
name=ob.readLine();
}
catch (IOException e) {
System.out.println("IO error trying to read your name!");
System.exit(1);
}
System.out.println("name is:" +name);
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.