title: How do I wait to see if my InputStream has received all data to process further?
body: <p>I have to write data to <code>Amazon S3</code> and I write data using <code>OutputStream</code> to its <code>InputStream</code> as follows</p>
  
  <pre><code>    final PipedOutputStream outputStream = new PipedOutputStream();
      final PipedInputStream inputStream;
      try {
          inputStream = new PipedInputStream(outputStream);
          new Thread(
                  new Runnable() {
                      @Override
                      public void run() {
                          PutObjectRequest putObjectRequest = new PutObjectRequest(S3EnvironmentConfigurator.BucketTypes.source.name(), getProposalName(uniqueId), inputStream, null);
                          amazonS3Client.putObject(putObjectRequest);
                          try {
                              inputStream.close();
                          } catch (IOException e) {
  
                          }
                      }
                  }
          ).start();
  </code></pre>
  
  <p>Now <code>amazonS3Client.putObject</code> looks like </p>
  
  <pre><code>  @Override
      public PutObjectResult putObject(@Nonnull final PutObjectRequest putObjectRequest)
              throws AmazonClientException, AmazonServiceException {
  
          try {
              InputStreamReader is = new InputStreamReader(new GZIPInputStream(putObjectRequest.getInputStream()));
              StringBuilder sb=new StringBuilder();
              BufferedReader br = new BufferedReader(is);
              String read = br.readLine();
              while(read != null) {
                  System.out.println(read);
                  read =br.readLine();
  
              }
          } catch (IOException e) {
              //ignore
          }
      return super.putObject(putObjectRequest);
  </code></pre>
  
  <ul>
  <li>This currently prints out the content on console</li>
  </ul>
  
  <p><strong>Needed</strong></p>
  
  <p>How can I do something like  </p>
  
  <pre><code>while (putObjectRequest.getInputStream() is not completely available) {
     // wait
  }
  
  // write inputStream, the entire InputStream is ready and available for processing
  </code></pre>