Simple timeout in java

Can anyone guide me on how I can use a simple timeout in java? Basically in my project I’m executing a statement br.readLine(), which is reading a response from a modem. But sometimes the modem isn’t responding. For that purpose I want to add a timeout. I’m looking for a code like:

try {
    String s= br.readLine();
} catch(TimeoutException e) {
    System.out.println("Time out has occurred");
}
[

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)