title: Updating a single line on a text file with a Java method
body: <p>I know previous questions LIKE this one have been asked, but this question has to do with the specifics of the code that I have written. I am trying to update a single line of code on a file that will be permanently updated even when the program terminates so that the data can be brought up again. The method that I am writing currently looks like this (no compile errors found with eclipse)</p>
  
  <pre><code>public static void editLine(String fileName, String name, int element,
              String content) throws IOException {
          try {
              // Open the file specified in the fileName parameter.
              FileInputStream fStream = new FileInputStream(fileName);
              BufferedReader br = new BufferedReader(new InputStreamReader(
                      fStream));
              String strLine;
              StringBuilder fileContent = new StringBuilder();
  
              // Read line by line.
              while ((strLine = br.readLine()) != null) {
                  String tokens[] = strLine.split(" ");
                  if (tokens.length &gt; 0) {
                      if (tokens[0].equals(name)) {
                          tokens[element] = content;
                          String newLine = tokens[0] + " " + tokens[1] + " "
                                  + tokens[2];
                          fileContent.append(newLine);
                          fileContent.append("\n");
                      } else {
                          fileContent.append(strLine);
                          fileContent.append("\n");
                      }
                  }
  
                  /*
                   * File Content now has updated content to be used to override
                   * content of the text file
                   */
                  FileWriter fStreamWrite = new FileWriter(fileName);
                  BufferedWriter out = new BufferedWriter(fStreamWrite);
                  out.write(fileContent.toString());
                  out.close();
  
                  // Close InputStream.
                  br.close();
              }
          } catch (IOException e) {
              System.out.println("COULD NOT UPDATE FILE!");
              System.exit(0);
          }
      }
  </code></pre>
  
  <p>If you could look at the code and let me know what you would suggest, that would be wonderful, because currently I am only getting my catch message.</p>