I have data coming from a bluetooth device, the data is being stored in an inputstream. I am taking the data from the inputstream and generating a graphic with Jfreechart. Whenever I turn off the bluetooth device the data keeps coming from the inputstream and the graphic continues being generated.
I need the data and the graphic to stop when I turn off the bluetooth device.
I am using Java.
Every InputStream has a close()
method that should do exactly what you need ... if you can detect that the device is turned off, that is.
Reference link : Closing java InputStream
which resolved my problem too.
Properties props = new Properties();
InputStream fis = new FileInputStream("message.properties");
try {
props.load(fis);
//omitted.
} catch (Exception ex) {
//omitted.
} finally {
try {
fis.close();
fis=null;
} catch (IOException ioex) {
//omitted.
}
}