title: How to write files to google cloud storage default bucket
body: <p>I am trying to write file to Google Cloud Storage (GCS) using the following code.</p>
  
  <pre><code>AppIdentityService appIdentityService = AppIdentityServiceFactory.getAppIdentityService();
  Stirng defaultBucketName = appIdentityService.getDefaultGcsBucketName();
  String fileName = "MyGcsFile-1.json";
  String mimeType = "application/json";
  GcsService gcsService = GcsServiceFactory.createGcsService();
  
  GcsFilename file = new GcsFilename(defaultBucketName, fileName);
  GcsFileOptions.Builder builder = new GcsFileOptions.Builder();
  GcsFileOptions options = builder.mimeType(mimeType).build();     
  GcsOutputChannel channel = gcsService.createOrReplace(file, options);
  PrintWriter writer = new PrintWriter(Channels.newWriter(channel, "UTF8"));
  writer.print(fileContent);
  writer.close();
  channel.close();
  </code></pre>
  
  <p>But when I try to fetch the file from GCS using code:</p>
  
  <pre><code>AppIdentityService appIdentityService = AppIdentityServiceFactory.getAppIdentityService();
  Stirng defaultBucketName = appIdentityService.getDefaultGcsBucketName();
  String fileName = "MyGcsFile-1.json";
  
  GcsService gcsService = GcsServiceFactory.createGcsService();
  GcsFilename gcsFile =  new GcsFilename(defaultBucketName, fileName);
  GcsInputChannel readChannel = gcsService.openReadChannel(gcsFile, new Long(0));
  InputStream is = Channels.newInputStream(readChannel);
  JsonFactory j = new JsonFactory();
  org.codehaus.jackson.JsonParser jp = j.createJsonParser(is);
  </code></pre>
  
  <p>getting the FileNotFoundException</p>
  
  <pre><code>java.io.FileNotFoundException
  at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:615)
  at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:594)
  at com.google.appengine.api.files.FileServiceImpl.read(FileServiceImpl.java:553)
  at com.google.appengine.api.files.FileServiceImpl.read(FileServiceImpl.java:431)
  at com.google.appengine.api.files.FileReadChannelImpl.read(FileReadChannelImpl.java:84)
  at com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService.readObjectAsync(LocalRawGcsService.java:271)
  at com.google.appengine.tools.cloudstorage.SimpleGcsInputChannelImpl$1.call(SimpleGcsInputChannelImpl.java:87)
  at com.google.appengine.tools.cloudstorage.SimpleGcsInputChannelImpl$1.call(SimpleGcsInputChannelImpl.java:81)
  at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:108)
  at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:166)
  at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156)
  at com.google.appengine.tools.cloudstorage.SimpleGcsInputChannelImpl.read(SimpleGcsInputChannelImpl.java:81)
  at sun.nio.ch.ChannelInputStream.read(Unknown Source)
  at sun.nio.ch.ChannelInputStream.read(Unknown Source)
  at sun.nio.ch.ChannelInputStream.read(Unknown Source)
  at org.codehaus.jackson.impl.ByteSourceBootstrapper.ensureLoaded(ByteSourceBootstrapper.java:507)
  at org.codehaus.jackson.impl.ByteSourceBootstrapper.detectEncoding(ByteSourceBootstrapper.java:129)
  at org.codehaus.jackson.impl.ByteSourceBootstrapper.constructParser(ByteSourceBootstrapper.java:224)
  at org.codehaus.jackson.JsonFactory._createJsonParser(JsonFactory.java:785)
  at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:561)
  </code></pre>
  
  <p>Where is the problem in the above code ? In writing file to GCS ? or Reading file from GCS ?</p>