title: Java - BufferedWriter not writing (after flush())
body: <p><strong>ANSWER:</strong>
  <em>You cannot write an int directly to a file. Convert it to a string first.</em></p>
  
  <hr>
  
  <p><strong>Original Question:</strong></p>
  
  <p>I know that this may sound like a nooby question, but I have nowhere else to turn.</p>
  
  <p>I'm trying to make Java write the Epoch (timestamp) to a .session file (don't ask). It doesn't seem to do anything. Here is what I have:</p>
  
  <pre><code>    gamesession = new File(SESSION_LOCATION);   // Sets the .session file
  
      if(gamesession.exists()){
          gamesession.delete();
          gamesession.createNewFile();
  
          FileWriter stream = new FileWriter(SESSION_LOCATION);
          BufferedWriter out = new BufferedWriter(stream);
  
          out.write(GetTimestamp());
          out.flush();
      }                       // These blocks write the Epoch to the .session file for later time
      else{
          gamesession.createNewFile();
  
          FileWriter stream = new FileWriter(SESSION_LOCATION);
          BufferedWriter out = new BufferedWriter(stream);
  
          out.write(GetTimestamp());
          out.flush();
      }
  </code></pre>
  
  <p>Yes, the method is <strong>DECLARED</strong> to throw a IOException (none occurs @ runtime). The problem is that, the .session file I'm writing to always turns up empty. Am I flushing wrong? Please help me shine some light on this. Thanks for your time.</p>
  
  <p><strong>FYI:</strong> The Epoch is calculated correctly, as I did <code>System.out.println(GetTimestamp())</code>.</p>
  
  <p><strong>GetTimestamp() is MY method. It is static.</strong></p>