10000 use try to create B2StorageClient · fishercoder1534/RandomJava@5a2420c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a2420c

Browse files
use try to create B2StorageClient
1 parent f90ad28 commit 5a2420c

File tree

1 file changed

+4
-2
lines changed

src/main/java/b2SdkExamples/B2SdkExamples.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ public static void main(String... args) throws B2Exception {
1919
// B2StorageClient client = B2StorageClientFactory.createDefaultFactory().create(USER_AGENT);
2020
//set up B2 CLI
2121
//and then use b2 get-account-info to get applicationKeyId and applicationKey to fill in here and run
22-
B2StorageClient client = B2StorageClientFactory.createDefaultFactory().create(APPLICATION_KEY_ID, APPLICATION_KEY, USER_AGENT);
23-
B2ListBucketsResponse b2ListBucketsResponse = client.listBuckets();
22+
B2ListBucketsResponse b2ListBucketsResponse;
23+
try (B2StorageClient client = B2StorageClientFactory.createDefaultFactory().create(APPLICATION_KEY_ID, APPLICATION_KEY, USER_AGENT)) {
24+
b2ListBucketsResponse = client.listBuckets();
25+
}
2426
List<B2Bucket> buckets = b2ListBucketsResponse.getBuckets();
2527
System.out.println("buckets.size() is: " + buckets.size());
2628
for (B2Bucket b2Bucket : buckets) {

0 commit comments

Comments
 (0)
0