static String checkBucketIsAccessible ( AmazonS3 amazonS3 , String bucketName ) { HeadBucketRequest headBucketRequest = new HeadBucketRequest ( bucketName ) ; try { amazonS3 . headBucket ( headBucketRequest ) ; } catch ( AmazonServiceException e ) { throw new AwsS3Exception ( "Bucket is not accessible" , args -> args . add ( "bucketName" , bucketName ) , e ) ; } return bucketName ; }
Throws an exception if the bucket does not exist or is not readable .