title: Java: Transfer local file to output stream of server
body: <p>I have a FileOutputStream and am trying to get the contents of this file on a remote server.  The server has an API to which I should POST the contents of the file (which is an .xls file).  The API requires me to POST the data to its API URL and set the ContentType to that of an .xls file in this case.</p>
  
  <p>The code is something as follows:</p>
  
  <pre><code>try { 
        outputFile = new FileOutputStream("myfile.xls");
  } 
  catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
  }
  
  handle.sendRequest("https://server/API/file/id", "POST", "application/vnd.ms-excel", data);
  </code></pre>
  
  <p>How can I send the data of the file in the stream to the server?</p>