IO流读取文章的问题
我在struts2的一个项目中,需要读取一篇文章,我数据库里面存放的是文章的路径,有以下代码,在j2se里能正确读取出文章,但是放在struts中就不能读取了。而且封装的方法根本就不执行。请问各位大牛这是怎么回事儿
代码:
public String getArticleContent(String path)
{
File file = new File(path);
String read = "";
StringBuilder sb = new StringBuilder();
InputStreamReader isr = null;
BufferedReader br = null;
try
{
isr = new InputStreamReader(new FileInputStream(file));
br = new BufferedReader(isr);
while ((read = br.readLine()) != null)
{
sb.append(read + "\n");
}
} catch (Exception e)
{
} finally
{
if (br != null)
{
try
{
br.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
if (isr != null)
{
try
{
isr.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
return sb.toString();
}
if (res != null)io流 Java 数据库
{
if (res.next())
{
title = res.getString("title");
content = getArticleContent(res
.getString("article_content"));
list.add(new ArticleBean(title, content));
System.out.println("文章路径----->>>"
+ res.getString("article_content"));
System.out.println(content);
} else
{
list.add(new ArticleBean("没有文章", null));
}
}