Hey. Do I catch the NullPointerException correctly in this case, or are there other, shorter ways?
try { try { numBytesRead = mPort.read(buffer, 1000); } catch (IOException e) { e.printStackTrace(); } }catch (NullPointerException e) {} Moreover, the mPort check for null not appropriate, because the error periodically occurs when I break the connection with my USB device, which at that moment sent the data, while mPort still exists, but an exception is thrown inside the read method.
Thank.