title: How to write an int value to a file?
body: <p>i am trying to implement file handling into a small project i am currently working on. At the moment i can read in and write out an array of objects to an external .txt document but i am also trying to write out an int value which keeps track of the unique id of the last added element to an array List.</p>
  
  <p>I am new to java, especially file handling. I am not sure if i can send in the int value along with the array list or if i need to create a new method and .txt document and write it to that. Below is what i have done so far, as you can see i have tried to send in the int with the array but this is as far as i can get.</p>
  
  <pre><code>public void writeToFile(List&lt;? extends Serializable&gt; team, int maleLastId) {
       try {
  
        outByteStream = new FileOutputStream(aFile);
        OOStream = new ObjectOutputStream(outByteStream);
  
        OOStream.writeObject(team);
  
        outByteStream.close();
        OOStream.close();
       } catch(IOException e) {
           JOptionPane.showMessageDialog(null,"I/O Error" + e + "\nPlease Contact your Administrator :-)");
       }
      }
  </code></pre>