title: how to update the contain in .txt file java
body: <p>for example i have the file named <code>file.txt</code> which contain personal information (id,name, salary):</p>
  
  <pre><code>A123 Anna 3000
  A234 Alex 4000
  A986 Jame 5000
  </code></pre>
  
  <p>How can I write a java code that allow user to enter an ID of a person and replenish salary?
  The final output will look like:</p>
  
  <p>Enter ID: A123</p>
  
  <p>Enter replenish salary: 2000</p>
  
  <p>file.txt after run the program:</p>
  
  <pre><code>A123 Anna 5000
  A234 Alex 4000
  A986 Jame 5000
  </code></pre>
  
  <p>This is what i have done so far but it didnt work:</p>
  
  <pre><code>public static void addDalary() throws IOException {
          String ID, Nanme;
          double salary;
  
  
              Scanner console = new Scanner(System.in);
              System.out.print("Enter ID : ");
              String pID = console.nextLine();
              System.out.print("Enter replenish salary: ");
              replenish = console.nextInt();
  
              Scanner input = new Scanner(new File("file.txt"));
              while (input.hasNext()) {
                  ID = input.next();
                  Name = input.next();
                  salary = input.nextDouble();
  
                  if (ID == pID) {    
                      salary = salary + replenish;
                  }
              }
              input.close();
          }
  </code></pre>
  
  <p>Im new to these things. Any help would be much appreciate.</p>