getcontent()正在截断页面内容

时间:2013-06-29 18:39:41

标签: android file-get-contents

任何人都可以帮到这里。它工作正常直到一个小时后,但突然停止正常工作(可能是网页内容被修改了更多信息)。

我正在将页面源代码(http://bkdrluhar.com/00-htm/Daily%20Murlis.htm)写入文件test.txt。但突然间它开始截断内容。文件test.txt被截断了!

以下是我的代码。如果你找到了什么,请建议。

protected void processMurlis(){
try {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("http://bkdrluhar.com/00-htm/Daily%20Murlis.htm");
    HttpResponse httpResponse = httpClient.execute(httpPost);
    HttpEntity httpEntity = httpResponse.getEntity();
    is = httpEntity.getContent();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"));
    BufferedWriter bw = new BufferedWriter(new FileWriter(Environment.getExternalStorageDirectory()+"/"+"test.txt"));
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
        currString = line.trim();
        sb.append(currString);
    } 
    bw.write(sb.toString());
    is.close(); 
    reader.close();
}catch(Exception e){
    errorMsg += "\nError: "+e.toString();
}
}

0 个答案:

没有答案