is there any way i can set a time limit for user input in a javaprogram?

A

Avi

I m taking some input from the user in a java program. and i wanna set
a time limit within which the user should provide this input. if no
input is provided during this time interval, the program sets the user
input to a space (ASCII code 32). other wise the user input is set to
whatever is entered by the user and the program moves on with
execution of the rest of the program.
Any help will b appreciated.
 
R

RedGrittyBrick

Avi said:
I m taking some input from the user in a java program. and i wanna set
a time limit within which the user should provide this input. if no
input is provided during this time interval, the program sets the user
input to a space (ASCII code 32). other wise the user input is set to
whatever is entered by the user and the program moves on with
execution of the rest of the program.
Any help will b appreciated.

Perhaps a solution would involve the use of java.util.Timer but it
probably depends on what classes you are using to get the input.
 
A

Arne Vajhøj

Avi said:
I m taking some input from the user in a java program. and i wanna set
a time limit within which the user should provide this input. if no
input is provided during this time interval, the program sets the user
input to a space (ASCII code 32). other wise the user input is set to
whatever is entered by the user and the program moves on with
execution of the rest of the program.
Any help will b appreciated.

Console or Swing app ?

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top