title: Java Replace Line In Text File
body: <p>How do I replace a line of text found within a text file?</p>
  
  <p>I have a string such as:</p>
  
  <pre><code>Do the dishes0
  </code></pre>
  
  <p>And I want to update it with:</p>
  
  <pre><code>Do the dishes1
  </code></pre>
  
  <p>(and vise versa)</p>
  
  <p>How do I accomplish this?</p>
  
  <pre><code>ActionListener al = new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      JCheckBox checkbox = (JCheckBox) e.getSource();
                      if (checkbox.isSelected()) {
                          System.out.println("Selected");
                          String s = checkbox.getText();
                          replaceSelected(s, "1");
                      } else {
                          System.out.println("Deselected");
                          String s = checkbox.getText();
                          replaceSelected(s, "0");
                      }
                  }
              };
  
  public static void replaceSelected(String replaceWith, String type) {
  
  }
  </code></pre>
  
  <p>By the way, I want to replace ONLY the line that was read.  NOT the entire file.</p>