Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Read standard input one character at a time (June 28, 1999)

The JavaWorld experts answer your most pressing Java questions -- every week

  • Print
  • Feedback

QIn a pure Java application how can you read standard input one character at a time (raw, unbuffered)?

A If the application has a GUI, it is possible to use a Component like java.awt.TextField to check each character as it is typed.

If the application is command-line based, the only portable way to read a single character from standard input through Java is to call System.in.read(). However, this call will block until the user types the <return> key at the end of a line, at which point the whole line is available for read().

About the author

Random Walk Computing is the largest Java/CORBA consulting boutique in New York, focusing on solutions for the financial enterprise. Known for their leading-edge Java expertise, Random Walk consultants publish and speak about Java in some of the most respected forums in the world.
  • Print
  • Feedback

Resources