FinalizationException - AppEngine Java Blobstore API

时间:2011-11-13 07:17:35

标签: java google-app-engine blob blobstore

我尝试使用实验Writing Files to Blobstore,甚至使用演示代码,我在尝试读取文件时不断收到FinalizationException。

我使用的代码如下:

FileService fileService = FileServiceFactory.getFileService();

AppEngineFile file = null;
file = fileService.createNewBlobFile("text/plain");

FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);

PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
out.println("The woods are lovely dark and deep.");
out.println("But I have promises to keep.");

out.close();
String path = file.getFullPath();

file = new AppEngineFile(path);

writeChannel = fileService.openWriteChannel(file, true);

writeChannel.write(ByteBuffer.wrap("And miles to go before I sleep.".getBytes()));

writeChannel.closeFinally();

我在另一个请求中获得FinalizationException的读取代码如下:

    FileService fileService = FileServiceFactory.getFileService();

    String path = //get the path code       
    AppEngineFile file = new AppEngineFile(path);

    FileReadChannel readChannel;
    try {
        readChannel = fileService.openReadChannel(file, false);
    } catch (FileNotFoundException e) { }

我在openReadChannel行

获得了Finalization Exception

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

此示例在开发服务器上正常工作。