在通过HttpResponse处理大型gzip压缩文件(10GB +)时,需要一些帮助解决MalformedChunkCodingException。
确切的错误消息是:块末尾的意外内容
我已将文件的CharEncoding设置为ASCII(但也尝试过UTF-8),在终端中运行以下命令确定:
file -bi "the file"
现在有些代码:
public BufferedReader getCSVAsBufferedReader() {
HttpResponse response = sendHttpRequest();
GZIPInputStream gzip = new GZIPInputStream(reponse.getEntity().getContent());
Reader reader = new InputStreamReader(gzip, CharEncoding.US_ASCII);
BufferedReader br = new BufferedReader(reader);
return br;
}
public void processBufferedReader(BufferedReader br){
String line;
while((line = reader.readLine() != null)){
//Do stuff to process that line
}
}
非常感谢任何帮助