title: Writing a File object to a file in java
body: <p>For a class, I have to send a file of any type from my client to a server. I have to handle each packet individually and use UDP. I have managed to transfer the file from the client to the server, and I now have a file object which I cannot figure out how to save to a user specified directory.</p>
  
  <pre><code>f = new File(path + '\\' + filename);//path and filename are user specified.
  FileOutputStream foutput = new FileOutputStream(f);
  ObjectOutputStream output = new ObjectOutputStream(foutput);
  output.writeObject(result);//result is a File
  output.flush();
  output.close();
  </code></pre>
  
  <p>Any time I run this code, it writes a new file with the appropriate name, but the text file I am testing ends up just containing gibberish. Is there any way to convert the File object to a file in the appropriate directory?</p>
  
  <p>EDIT: As it turns out, I was misunderstanding what, exactly, a file is. I have not been transferring the data, but rather the path. How do I transfer an actual file?</p>