title: Search RandomAccessFile String Display
body: <p>I'm Working on a project. </p>
  
  <p>I need to read and display a record that holds a student ID and Name . that user has entered (read by ID)</p>
  
  <p>I wrote to the file using writeUTF and ArrayList ..</p>
  
  <p>public void readFile(String sID) throws Exception{</p>
  
  <pre><code>    studentID = sID;  // take passed variable
  
  
      try {
          //open read file 
          RandomAccessFile sFile = new RandomAccessFile("newStudent.dat", "r");
  </code></pre>
  
  <p>//** I dont understand this long length section.</p>
  
  <pre><code>        long pos = sFile.length();  // Get length of File 
  
          sFile.seek(pos); //moves pointer , I get this, but Why?
  
          for (int i = 0; i &lt; sFile.length(); i++) {
  
              //read the file 
  
              String result = sFile.readUTF();
  
              if (result.equals(studentID)) 
  </code></pre>
  
  <p>//**here I want to print whole record with the name </p>
  
  <pre><code>            System.out.print(result); // testing print
          }
           sFile.close();
  
  
      } catch (IOException e) {
          System.out.print("test File caught ");
  </code></pre>
  
  <p>Once this is complete I will need to do a read and replace record. </p>
  
  <p>I'm lost at this point , any possible suggestions. I've some similar posts 
  and I'm not understanding what I need to fix.
  I just need to test this before I build out the JDesktopPane and JInternalFrame
  simplicity is my goal at this point. </p>
  
  <p>thank you for anyfeedback or I direction</p>