title: Editing existing txt file in java
body: <p>I have class Account which have username, fullName, password, id and points.
  All accounts are saved in a file.I have many accounts in my file, not just one. This is example of one account in text file.</p>
  
  <pre><code>Miljan9602 Rakita Miljan miljan123 1463433398614 0.0
  </code></pre>
  
  <p>username, full name, password, id and points</p>
  
  <p>Now, for example if i want to change points for my username. First thing i would do is go through all lines in file and compare all usernames, if i find equal username. I would change point's. This is my idea how to do it. Just dont know how to edit it in file.</p>
  
  <pre><code>public void edit(String username, double points)
  {
      File f = new File("Accounts.txt");
  
      // file doesnt exist, return from method
      if(!f.exists())
          return;
      Scanner sc = null;
  
      try
      {
          sc = new Scanner(f);
  
          while(sc.hasNextLine())
          {
              String line = sc.nextLine(); // Take whole line
              String split[] = line.split(" "); // Split it so i can check username
  
              if(split[0].equals(username))
              {
                  String change = Double.toString(points); // Make string from double
                  split[5] = change; // on fifth index are points
  
                  /* My question is now how to edit file and to replace my new points
                   * with old points ?
                   *  Miljan9602 Rakita Miljan miljan123 1463433398614 0.0 &lt;- Need to change this 0.0 with split[4];
                   */
              }
          }
      }catch(Exception e)
      {
          e.printStackTrace();
      }finally{
          // finally will always close file
          sc.close();
      }
  </code></pre>