title: Modifying existing file content in Java
body: <p>I want to replace the second line file content, can somebody help please based on the below file format and listener method.</p>
  
  <pre><code>1324254875443
  1313131
  Paid
  0.0
  </code></pre>
  
  <p>2nd line is long and want to replace to <code>currentTimeMillis()</code>.</p>
  
  <pre><code>/************** Pay Button Listener **************/
  public class payListener implements ActionListener {
      public void actionPerformed(ActionEvent e) {
  
          ArrayList&lt;String&gt; lines = new ArrayList&lt;String&gt;();
          String line = null;
  
          try {
              FileReader fr = new FileReader("Ticket/" + ticketIDNumber + ".dat");
              BufferedReader br = new BufferedReader(fr);
              FileWriter fw = new FileWriter("Ticket/" + ticketIDNumber + ".dat");
              BufferedWriter bw = new BufferedWriter(fw);
              while ((line = br.readLine()) != null) {
                  if (line.contains("1313131"))
                      line.replace(System.currentTimeMillis();
                  lines.add(line);
                  bw.write(line);
              }  //end if                 
  
          }     //end try
          catch (Exception e) {
  
          }  //end catch   
      }    //end while
  }//end method
  </code></pre>