title: Is there a way to read information from a saved file to check if there is an already exisiting doctorID saved?
body: <p>So I am trying to create a Medical Clinic System Management program for a school project. This is my first project using NetBeans to create a GUI and unfortunately, my class spent about two weeks on the topic so I am not as well versed in this as I wish I was. So please don't be too harsh on my code. When I create a doctor object, the data gets saved to a file. When I go back and attempt to create another doctor with the same ID, my boolean isKeyPresent does not catch it because (I'm assuming) my doctor map is not associated with any of the doctors created in the save file. How can I fix this, so my system does not make a doctor if the ID is already in use?</p>
  <pre><code>private void btnAddDoctorActionPerformed(java.awt.event.ActionEvent evt) {                                             
          
          try {
              
              String id = txtDocID.getText();
              String name = txtDocName.getText();
              String specialty = txtSpecialty.getText();
          
              boolean isKeyPresent = administrative.doctors.containsKey(id);
              if(isKeyPresent) {
              
                  JOptionPane.showMessageDialog(this, &quot;Doctor ID Already Exists&quot;);
              }
              else {
              
                  addDoctor(name, specialty, id);
                  String s = name + &quot;,&quot;;
                  s += specialty + &quot;,&quot;;
                  s += id;
              
                  FileWriter w = new FileWriter(fileLocation);
                  BufferedWriter writer = new BufferedWriter(w);
                  writer.write(s);
                  writer.close();
                  JOptionPane.showMessageDialog(this, &quot;Doctor Added&quot;);
              }        
              txtDocID.setText(&quot;&quot;);
              txtDocName.setText(&quot;&quot;);
              txtSpecialty.setText(&quot;&quot;);
          }
          catch(IOException e) {
              
              JOptionPane.showMessageDialog(this, &quot;File Error&quot;);
          }
      }
  </code></pre>