1

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

我正在将页面源代码(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();
}
}
4

0 回答 0