cleaning up stop/dispose events

This commit is contained in:
benfry
2012-11-25 17:41:33 +00:00
parent 03b5baa8b7
commit 8b771c0d98
3 changed files with 51 additions and 38 deletions

View File

@@ -225,23 +225,31 @@ public class Serial implements SerialPortEventListener {
*/
public void dispose() {
try {
// do io streams need to be closed first?
if (input != null) input.close();
if (output != null) output.close();
if (input != null) {
input.close();
input = null;
}
} catch (Exception e) {
e.printStackTrace();
}
input = null;
output = null;
try {
if (port != null) port.close(); // close the port
if (output != null) {
output.close();
output = null;
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (port != null) {
port.close();
port = null;
}
} catch (Exception e) {
e.printStackTrace();
}
port = null;
}