langxiashahai 2010-06-11 11:42
浏览 434
已采纳

java快速读取html文件内容的算法,请赐教.......

[code="java"]File file = new File(path);
try {
if (!file.exists() || file.isDirectory())
throw new FileNotFoundException();
BufferedInputStream in = new BufferedInputStream(
new FileInputStream(file));
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1) {
out.write(temp, 0, size);
}
in.close();
String encod_char = findCharSet(out.toString());
return out.toString(encod_char);
} catch (IOException ie) {
ie.printStackTrace();
}
return null;[/code]

这个是我写的一个读取文件的方法,不知道还有没有更高效的算法。还请大家赐教。。。。执行效率大约在30-50MS之间。

  • 写回答

3条回答 默认 最新

  • JavaHero080 2010-06-13 14:35
    关注

    我想说的是InputStreamReader是[b]可以指定编码方式的[/b]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器