code: public GetDocumentStreamResult getDocumentStream(final GetDocumentStreamRequest getDocumentStreamRequest) {
          String versionId = getDocumentStreamRequest.getVersionId();
          if (versionId == null) {
              GetDocumentRequest getDocumentRequest = new GetDocumentRequest();
              getDocumentRequest.setDocumentId(getDocumentStreamRequest.getDocumentId());
              
              String requestAuthenticationToken = getDocumentStreamRequest.getAuthenticationToken();
              if (requestAuthenticationToken != null) {
                  getDocumentRequest.setAuthenticationToken(requestAuthenticationToken);
              } else {
                  getDocumentRequest.setAuthenticationToken(authenticationToken);
              }
  
              GetDocumentResult result = client.getDocument(getDocumentRequest);
              versionId = result.getMetadata().getLatestVersionMetadata().getId();
          }
  
          GetDocumentStreamResult getDocumentStreamResult = new GetDocumentStreamResult(getDocumentStreamRequest);
          getDocumentStreamResult.setVersionId(versionId);
          InputStream stream = getDocumentVersionStream(getDocumentStreamRequest.getDocumentId(), versionId);
          getDocumentStreamResult.setStream(stream);
  
          return getDocumentStreamResult;
      }
docs: Gets document stream from WorkDocs.
  If VersionId of GetDocumentStreamRequest is not specified,
  then the latest version of specified document is retrieved.
  Clients must close the stream once content is read.
  
  @param getDocumentStreamRequest Request specifying parameters of the operation.
  @return Result containing stream of requested document content.