code: private static URI convertToVirtualHostEndpoint(URI endpoint, String bucketName) {
          try {
              return new URI(String.format("%s://%s.%s", endpoint.getScheme(), bucketName, endpoint.getAuthority()));
          } catch (URISyntaxException e) {
              throw new IllegalArgumentException("Invalid bucket name: " + bucketName, e);
          }
      }
docs: Converts the current endpoint set for this client into virtual addressing style, by placing
  the name of the specified bucket before the S3 service endpoint.
  
  @param bucketName The name of the bucket to use in the virtual addressing style of the returned URI.
  @return A new URI, creating from the current service endpoint URI and the specified bucket.