Skip to content

Commit ff6ca12

Browse files
authored
---
yaml --- r: 8323 b: refs/heads/snehashah-snippets c: 760ea21 h: refs/heads/master i: 8321: 963ea39 8319: 934293b
1 parent 5fee2e1 commit ff6ca12

2 files changed

Lines changed: 10 additions & 18 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5656
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5757
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5858
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
59-
refs/heads/snehashah-snippets: bf78f325cddc94de079f1b5086c7e823a229de03
59+
refs/heads/snehashah-snippets: 760ea21905d2ec3fb4d0203cff138aa0df4cce04
6060
refs/tags/v0.20.2: 5a53aa06f268b74dc192204f4f83e1a04d40f65d
6161
refs/tags/v0.20.3: 269025fdc14af0b68df214a4518be5379b2fe569
6262
refs/tags/v0.21.0: f88b200e00e41ba6262ee88a92abba38b1e2417e

branches/snehashah-snippets/google-cloud-storage/README.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,19 @@ String blobContent = new String(blob.getContent(), UTF_8);
113113
```
114114

115115
#### Listing buckets and contents of buckets
116-
Suppose that you've added more buckets and blobs, and now you want to see the names of your buckets and the contents of each one. Add the following imports:
117-
118-
```java
119-
import java.util.Iterator;
120-
```
121-
122-
Then add the following code to list all your buckets and all the blobs inside your newly created bucket.
116+
Suppose that you've added more buckets and blobs, and now you want to see the names of your buckets and the contents of each one. Add the following code to list all your buckets and all the blobs inside each bucket.
123117

124118
```java
125119
// List all your buckets
126-
Iterator<Bucket> bucketIterator = storage.list().iterateAll();
127120
System.out.println("My buckets:");
128-
while (bucketIterator.hasNext()) {
129-
System.out.println(bucketIterator.next());
130-
}
131-
132-
// List the blobs in a particular bucket
133-
Iterator<Blob> blobIterator = bucket.list().iterateAll();
134-
System.out.println("My blobs:");
135-
while (blobIterator.hasNext()) {
136-
System.out.println(blobIterator.next());
121+
while (Bucket bucket : storage.list().iterateAll()) {
122+
System.out.println(bucket);
123+
124+
// List all blobs in the bucket
125+
System.out.println("Blobs in the bucket:");
126+
for (Blob blob : bucket.list().iterateAll()) {
127+
System.out.println(blob);
128+
}
137129
}
138130
```
139131

0 commit comments

Comments
 (0)