Google の例を使用すると、これがファイルを読み取ろうとしている方法です。
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)
ヘルプ!