关于异常,这样对吗? 楼主这样都想得到^_^,有创意^_^我说finally里面加try catch.我觉得行^_^(没试过,理论上应该行哈哈) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public String get(){ InputStream filecon = null ; try { filecon = fileurl.openStream(); Content = extractor.extractText(filecon); } catch (IOException e) { System.out.println("OpenStream failed"); } finally { try { if(filecon!=null) { filecon.close(); } } catch(IOException e) { System.out.println("Close file failed"); } } return Content; }xiusdf 对的,没有问题的.不过没看到fileurl的声明 谢谢大家,fileurl在外面有声明了。结贴, finally的使用完全正确的,用了try也是非常对和必须的 finally里直接写filecon.close();就行了,没见过这样写。 对啊,就是这样的,你去网上看看关闭数据库连接的方式也是这样写的,在finally里写,还要try-catch异常的 中文编码问题-在线等 电脑出漏洞拉,修复不了咋办...... 请问那些类中有可以自动执行的paint()方法! 急!JAVA实现串口通讯问题! java中如何操作sqlserver中的text类型字段 问个myeclipse小问题 applet 的html页面显示怎么只有一块灰色的空白啊? 问环境配置问题. 除了SmartUpload之外还有其他好的上传组件吗? actionPerformed方法是会自动执行吗? 关于class的加载问题~~ JAVA如何从命令行读入一个String呢
{
InputStream filecon = null ;
try
{
filecon = fileurl.openStream();
Content = extractor.extractText(filecon);
}
catch (IOException e)
{
System.out.println("OpenStream failed");
}
finally
{
try
{
if(filecon!=null)
{
filecon.close();
}
}
catch(IOException e)
{
System.out.println("Close file failed");
}
}
return Content;
}
xiusdf
就行了,没见过这样写。