title: Using Java APIs for downloading file from the Google Drive
body: <p>I am using the Java APIs for creating an application. However I am not able to crack the problem of downloading a file from the drive.</p>
  
  <p>I am trying to use the function given on Google Developer's page. (Link below)</p>
  
  <p><a href="https://developers.google.com/drive/manage-downloads" rel="nofollow">https://developers.google.com/drive/manage-downloads</a></p>
  
  <p>However, it is not clearly mentioned how to get/generate downloadURI for a specific file. And also I am confused how to download the file using the downloadURI.</p>
  
  <p>I am using the following function- </p>
  
  <pre><code>private static InputStream downloadFile(Drive service, File file) 
  {
      if (file.getDownloadUrl() != null &amp;&amp; file.getDownloadUrl().length() &gt; 0) 
      {
        try 
        {
          HttpResponse resp = service.getRequestFactory().buildGetRequest
                       (new GenericUrl(file.getDownloadUrl())).execute();
          return resp.getContent();
        }
        catch (IOException e) 
        {
          e.printStackTrace();
          return null;
        }
      } 
      else 
      {
       return null;
      }
   }
  </code></pre>
  
  <p>Here I am not able to get what file should be the input parameter for the function.
  Please help me out.</p>