我尝试使用实验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
如有任何帮助,我们将不胜感激。
最佳答案
此示例在开发服务器上运行良好。
关于java - FinalizationException - AppEngine Java Blobstore API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8110207/