【发布时间】:2011-12-27 22:54:24
【问题描述】:
我尝试使用实验性的 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 行得到了终结异常
任何帮助将不胜感激。
【问题讨论】:
-
你解决了什么问题吗?我遇到了类似的问题
-
第二,这个问题你解决了吗?
标签: java google-app-engine blob blobstore