Examples of closeFinally()


Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    AppEngineFile file = newBlob(mimeType, downloadFilename);
    FileWriteChannel out = getFileService().openWriteChannel(file, true);
    while (bytes.hasRemaining()) {
      out.write(bytes);
    }
    out.closeFinally();
    // Verify if what's in the file matches what we wanted to write -- the Files
    // API is still experimental and I've seen it misbehave.
    bytes.rewind();
    byte[] expected = getBytes(bytes);
    byte[] actual = slurp(file);
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    AppEngineFile blobFile = fileService.createNewBlobFile("application/bin");
    FileWriteChannel writeChannel = fileService.openWriteChannel(blobFile, true);
    for (int i = 0; i < RECORDS_COUNT; i++) {
      writeChannel.write(ByteBuffer.wrap(RECORD.getBytes()));
    }
    writeChannel.closeFinally();
    blobKey = fileService.getBlobKey(blobFile);
    blobSize = new BlobInfoFactory().loadBlobInfo(blobKey).getSize();
  }

  @Override
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

  private void writeAll() throws IOException {
    FileWriteChannel writer = file.openWriteChannel();
    ByteBuffer toWrite = ByteBuffer.wrap(bytes);
    writer.write(toWrite);
    writer.closeFinally();
  }

  @Override
  protected void flushBuffer(byte[] b, int offset, int length) throws IOException {
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

        PrintWriter writer = new PrintWriter(Channels.newWriter(writeChannel, encoding));

        IOGroovyMethods.withWriter(writer, closure);

        if (closeFinally) {
            writeChannel.closeFinally();
        } else {
            writeChannel.close();
        }

        return file;
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

        OutputStream stream = Channels.newOutputStream(writeChannel);

        IOGroovyMethods.withStream(stream, closure);

        if (closeFinally) {
            writeChannel.closeFinally();
        } else {
            writeChannel.close();
        }

        return file;
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    FileWriteChannel writeChannel = fileService
        .openWriteChannel(file, true);
    // This time we write to the channel directly
    writeChannel.write(ByteBuffer.wrap(data));
    // Now finalize
    writeChannel.closeFinally();
    if (blobKey != null)
      try {
        deleteBlobKey(blobKey);
      } catch (IOException e) {
        // some error in deleting blob, google app issue
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    // This time we write to the channel directly
    writeChannel.write(ByteBuffer.wrap(data));
    // Now finalize
    writeChannel.closeFinally();
    //if(blobKey !=null) //delete the existing blob first -- GOT ERROR here....
    //    blobstoreService.delete(blobKey);
    // Now read from the file using the Blobstore API
    blobKey = fileService.getBlobKey(file);
    String[] json = {blobKey.getKeyString()};
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

        .openWriteChannel(file, true);
    PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel,
        "UTF8"));
    out.println("Hello");
    out.close();
    writeChannel.closeFinally();

    BlobKey bk = fileService.getBlobKey(file);
    String imageKeyStr = bk.getKeyString();
    return imageKeyStr;
  }
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    AppEngineFile file = fileService.createNewBlobFile("image/jpeg");
    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    OutputStream out = (Channels.newOutputStream(writeChannel));
    out.write(bytes);
    out.close();
    writeChannel.closeFinally();
   
    return fileService.getBlobKey(file);
  }
 
  public void updateBlob(Entity entity, String blobField, byte[] bytes) throws ServletException {
View Full Code Here

Examples of com.google.appengine.api.files.FileWriteChannel.closeFinally()

    AppEngineFile file = fileService.createNewBlobFile("image/jpeg");
    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
    out.println("Hello");
    out.close();
    writeChannel.closeFinally();
   
    BlobKey bk = fileService.getBlobKey(file);
    return bk;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.