Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control - C exception in Java

I need to catch that exception but I can't figure out which one it is. The IDE i'm using right now doesn't allow for a program interrupt that way.

I know how to user try/catch, but I don't actually know what I'm trying to catch..

Can anyone help me with this?

like image 742
Phil Avatar asked Oct 24 '25 18:10

Phil


1 Answers

I seem to recall that CTRL-C becomes an InterruptedException and this article seems to support that. As suggested in other answers the use of addShutdownHook is a good way to go, unless you want to prevent the shutdown.

like image 126
torak Avatar answered Oct 26 '25 09:10

torak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!