title: Convert filleoutputstream to a file java
body: <p>Good Day</p>
  
  <p>I am downloading a file using ftpclient, and is downloading successfully, I however have a problem converting this to a file</p>
  
  <p>For example I am downloading a file called "helper.pdf" and I want to download the file as is to a local file called "helper.pdf"</p>
  
  <p>Here is my code</p>
  
  <pre><code>FTPClient client = new FTPClient();
    FileOutputStream fos = null;
    try
    {
       client.connect(Host);
       client.login(user_ftp, password_ftp);
       if (client.changeWorkingDirectory("workingdirectory"))
       {            
          fos = new FileOutputStream(Copy_file);
          if (client.retrieveFile(Copy_file, fos))
          {
             //System.out.println("FOS : "+fos.toString());
             //ObjectInputStream restore_file = new ObjectInputStream(fos);
          }            
          fos.close();
       }
       JOptionPane.showMessageDialog(null, "Downloaded", "Info", JOptionPane.INFORMATION_MESSAGE);
    }
    catch (Exception err)
    {
       JOptionPane.showMessageDialog(null, "Error downloading update file", "Error", JOptionPane.ERROR_MESSAGE);
    }
  </code></pre>
  
  <p>So the question is how do I convert the FileOutputStream to a pdf or save it as a pdf file.</p>