Java, How do I caputre a control C from the command line

I wrote a quick java program that runs in an infinite loop.

I want to be able  to capture a CNL - C, and terminate the program with a message

How can I do this, could someone please post an example

Los Angeles1Asked:
Who is Participating?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.