title: Write real time data to file
body: <p>How to write real time data to file in Java?</p>
  
  <p>I'm trying to get real time twitter feed to text file. Here is a code that I have written:</p>
  
  <pre><code>public void onStatus(Status status) 
  {
     User user = status.getUser();
     BufferedWriter bufferedWriter = null;
     try
     {
        bufferedWriter = new BufferedWriter(new FileWriter("c:\\twitterDumponFile.txt"));
        String username = status.getUser().getScreenName();
        bufferedWriter.write(username);
  
        String profileLocation = user.getLocation();
        bufferedWriter.write(profileLocation);
  
        String content = status.getText();
        bufferedWriter.write(content);
        bufferedWriter.newLine();
  
     }
     catch (FileNotFoundException ex) 
     {
        ex.printStackTrace();
     } 
     catch (IOException ex) 
     {
        ex.printStackTrace();
     } 
     finally
     {
        //Closing the BufferedWriter
        try
        {
           if (bufferedWriter != null) 
           {
              bufferedWriter.flush();
              bufferedWriter.close();
           }
        } 
        catch (IOException ex) 
        {
           ex.printStackTrace();
        }
     }
  } 
  </code></pre>
  
  <p>When I open the file twitterDumponFile.txt it contains a single line of data. Everytime I open it it has a different data but a single line, it is not appending the new data on to the file.</p>
  
  <p>Please help me where I'm getting wrong.</p>