Top three ways to handle Java user input in a standalone Java app

This tutorial looks at three ways a Java app can handle input: using the Scanner, using the System's console object, and using a Swing component.

Computer programs, in their simplest form, really just do three things: First, they take input from the user; secondly, they manipulate that input in some manner; and thirdly, they send a response back to the client informing the user about how their input was handled. Interestingly, however, handling user input in a standalone Java application has always been rather onerous since it requires the use of InputStream objects and various esoteric input and output classes. Fortunately, additions to the JDK over the years have helped to simplify the task of obtaining input from the user. In this tutorial, the third in a series, we look at three of the best ways to handle user input in a simple, standalone Java application -- by using the Scanner class, the System's console object and the Swing package's JOptionPane.

This was last published in August 2012

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudApplications

SearchSOA

SearchSoftwareQuality

SearchFinancialApplications

SearchSAP

SearchManufacturingERP

Close