import java.io.* ; public class Thermometer { int temperature ; FileWriter fw ; public Thermometer() { try { fw = new FileWriter("mylog",true) ; } catch (Exception e) { } } public void log(){ try { fw.write(":" + temperature) ; fw.flush() ; } catch (Exception e) { } } static public void main(String[] args) { Thermometer t = new Thermometer() ; t.log() ; t.log() ; Thermometer u = new Thermometer() ; u.log() ; u.log() ; u.log() ; //try { new FileWriter("mylog") ; } //catch (Exception e) { } } }