最近,我尝试使用google-api-java-client库来访问google文档。我可以使用这个库来获取列表,创建新文档,并成功更新。然而,当我想要从Google Document下载一个大文件(> 10mb)时,它会导致OutOfMemoryError。
03-30 17:57:10.650: E/AndroidRuntime(11022): java.lang.OutOfMemoryError
03-30 17:57:10.650: E/AndroidRuntime(11022): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
03-30 17:57:10.650: E/AndroidRuntime(11022): at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.AbstractInputStreamContent.copy(AbstractInputStreamContent.java:213)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.AbstractInputStreamContent.copy(AbstractInputStreamContent.java:179)
03-30 17:57:10.650: E/AndroidRuntime(11022): at com.google.api.client.http.HttpResponse.getContent(HttpResponse.java:384)这是我的代码:
try {
...
HttpRequest request = getRequestFactory().buildGetRequest(link);
HttpResponse response = request.execute();
InputStream is = response.getContent();
...
} catch (IOException e) {
e.printStackTrace();
}响应码是200,可以在小文件上成功工作。有没有使用google-api-java-client下载大文件的方法?
发布于 2012-04-07 20:43:12
感谢您报告此问题!在我看来像是个虫子。在这里归档:
http://code.google.com/p/google-http-java-client/issues/detail?id=82
作为解决办法,请禁用此请求的日志记录,如下所示:
request.setContentLoggingLimit(0);https://stackoverflow.com/questions/9941378
复制相似问题