title: Reading and writing simultaneously java
body: <p>I am working on java Application where I am dealing with read and
  write file. But I want to do this process simultaneously.  As my file
  is log file from which I am reading contents by some time interval for
  this I used <code>java.util.Timer</code>. And during this time interval I am trying
  to writing some contents in the file, but this is not updating in my
  log file.</p>
  
  <p><strong>My Timer class is</strong></p>
  
  <pre><code>public class Timer extends java.util.Timer {
  
   public void startTimer() {
    Timer t = new Timer();
    Task task = new Task();
    t.schedule(task, 0, 10000);
   }
  }
  </code></pre>
  
  <p><strong>My class form which file read write class is called</strong></p>
  
  <pre><code>public class Task extends TimerTask {
  
   @Override
   public void run() {
    System.out.println("In task ....");
    try {
     SMSQuestions smsQuestions = new SMSQuestions();
  
     smsQuestions.sendSMSAnswer();
    }
    catch(Exception e)
    {
     e.printStackTrace();
    }
   }
  }
  </code></pre>
  
  <p><strong>My file read write class is</strong></p>
  
  <pre><code>public void sendSMSAnswer()
      {
          long sender;
          String question;
  
          try {
              BufferedReader br = new BufferedReader(new FileReader("C:/temp/NowSMS/TEST.log"));
              String line = br.readLine();
  
              while (line != null) {
                  sender = 0;
                  question = "";
                  System.out.println(line);
                  line = br.readLine();
              }
              //To delete all contents in file
              BufferedWriter bw = new BufferedWriter(new FileWriter("C:/temp/NowSMS/TEST.log"));
              bw.write("");
  
              getDetails();
  
          }catch(Exception exp)
          {
              exp.printStackTrace();
          }
      }
  </code></pre>
  
  <p>My problem is when i updated my log file by writing new contents it
  can't be updated so my question is: is it possible in java to simultaneously read write file or not?</p>