public boolean doesBucketExist ( DoesBucketExistRequest request ) { checkNotNull ( request , "request should not be null." ) ; try { this . invokeHttpClient ( this . createRequest ( request , HttpMethodName . HEAD ) , BosResponse . class ) ; return true ; } catch ( BceServiceException e ) { // Forbidden means that the bucket exists. if ( e . getStatusCode ( ) == StatusCodes . FORBIDDEN ) { return true ; } if ( e . getStatusCode ( ) == StatusCodes . NOT_FOUND ) { return false ; } throw e ; } }
Checks if the specified bucket exists . Bos buckets are named in a global namespace ; use this method to determine if a specified bucket name already exists and therefore can t be used to create a new bucket .