使用谷歌的例子,这是我试图读取我的文件的方式:
boolean lockForRead = false;
String filename = "/gs/my_bucket/my_object";
AppEngineFile readableFile = new AppEngineFile(filename);
FileReadChannel readChannel = fileService.openReadChannel(readableFile, lockForRead);
// Read the file in whichever way you'd like
BufferedReader reader = new BufferedReader(Channels.newReader(readChannel, "UTF8"));
String line = reader.readLine();
resp.getWriter().println("READ:" + line);
readChannel.close();
但是,代码与 reader.readLine 行完美结合,并在该行引发异常:
java.io.IOException
at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:615)
……
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 7: ...\war\WEB-INF\appengine-generated\encoded_gs_key:L2dzL21hcGxlL3NhdmUudHh0 (The system cannot find the file specified)
帮助!