title: How to download GZip file from S3?
body: <p>I have looked at both <a href="https://stackoverflow.com/questions/6903255/aws-s3-java-sdk-download-file-help">AWS S3 Java SDK - Download file help</a> and <a href="https://stackoverflow.com/questions/3711282/working-with-zip-and-gzip-files-in-java">Working with Zip and GZip files in Java</a>. </p>
  
  <p>While they provide ways to download and deal with files from S3 and GZipped files respectively, these do not help in dealing with a GZipped file located in S3. How would I do this? </p>
  
  <p>Currently I have:</p>
  
  <pre><code>try {
      AmazonS3 s3Client = new AmazonS3Client(
              new ProfileCredentialsProvider());
      String URL = downloadURL.getPrimitiveJavaObject(arg0[0].get());
      S3Object fileObj = s3Client.getObject(getBucket(URL), getFile(URL));
      BufferedReader fileIn = new BufferedReader(new InputStreamReader(
              fileObj.getObjectContent()));
      String fileContent = "";
      String line = fileIn.readLine();
      while (line != null){
          fileContent += line + "\n";
          line = fileIn.readLine();
      }
      fileObj.close();
      return fileContent;
  } catch (IOException e) {
      e.printStackTrace();
      return "ERROR IOEXCEPTION";
  }
  </code></pre>
  
  <p>Clearly, I am not handling the compressed nature of the file, and my output is:</p>
  
  <pre><code>����sU�3204�50�5010�20�24��L,(���O�V�M-.NLOU�R�U�����&lt;s��&lt;#�^�.wߐX�%w���������}C=�%�J3��.�����둚�S�ᜑ���ZQ�T�e��#sr�cdN#瘐:&amp;�
  S�BǔJ����P�&lt;��
  </code></pre>
  
  <p>However, I cannot implement the example in the <a href="https://stackoverflow.com/questions/3711282/working-with-zip-and-gzip-files-in-java">second question</a> given above because the file is not located locally, it requires downloading from S3.</p>
  
  <p>What should I do?</p>