Skip to content

Instantly share code, notes, and snippets.

@tedheich
Created November 26, 2009 13:50
Show Gist options
  • Save tedheich/243470 to your computer and use it in GitHub Desktop.
Save tedheich/243470 to your computer and use it in GitHub Desktop.
Code to accept keyboard input in Java
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
class AcceptInputFromKB {
public static void main(String []args) throws IOException {
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (isr);
System.out.print("% ");
String temp = br.readLine();
System.out.println(temp);
System.out.println("Length of string = " + temp.length());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment