@@ -102,27 +102,28 @@ See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to
102102with the Cloud Storage using this Client Library.
103103
104104``` java
105+ import static java.nio.charset.StandardCharsets.UTF_8 ;
106+
105107import com.google.gcloud.storage.Blob ;
106108import com.google.gcloud.storage.Storage ;
107109import com.google.gcloud.storage.StorageFactory ;
108110import com.google.gcloud.storage.StorageOptions ;
111+
109112import java.nio.ByteBuffer ;
110113import java.nio.channels.WritableByteChannel ;
111114
112115StorageOptions options = StorageOptions . builder(). projectId(PROJECT_ID ). build();
113116Storage storage = StorageFactory . instance(). get(options);
114- byte [] content = readContent();
115117Blob blob = new Blob (storage, " bucket" , " blob_name" );
116118if (! blob. exists()) {
117- storage . create(blob. info(), content );
119+ storage2 . create(blob. info(), " Hello, Cloud Storage! " . getBytes( UTF_8 ) );
118120} else {
119121 System . out. println(" Updating content for " + blob. info(). name());
120122 byte [] prevContent = blob. content();
121- content = mergeContent (prevContent, content );
123+ System . out . println( new String (prevContent, UTF_8 ) );
122124 WritableByteChannel channel = blob. writer();
123- channel. write(ByteBuffer . wrap(content));
125+ channel. write(ByteBuffer . wrap(" Updated content" . getBytes( UTF_8 ) ));
124126 channel. close();
125- }
126127}
127128```
128129
0 commit comments