读取jsp页面内容解决办法

   阅读
读取jsp页面内容
我在浏览当前页面的时候直接把当前页面的内容放入物理路径中的一个文件当中,可我在jsp页面当中写入
URL url = new URL(indexurl);
InputStreamReader isr = new InputStreamReader(url.openStream());
BufferedReader br = new BufferedReader(isr);
FileOutputStream fileout = new FileOutputStream(addtext);
String str;
while ((str = br.readLine()) != null) {
fileout.write(str.getBytes());
}
发生了死循环,一执行到FileOutputStream fileout = new FileOutputStream(addtext);就又回去了,怎么回事啊??

------解决方案--------------------
public String getPageSource(String urlstr){
String code = "";
URLConnection uc = null;
URL url = null;
BufferedReader br = null;
try{
String tmp = "";
url = new URL(urlstr);
uc = url.openConnection();
uc.setConnectTimeout(1000 * 30);
uc.setReadTimeout(1000 * 30);
br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
while((tmp = br.readLine()) != null){
if(tmp.trim().length() > 0){
code += tmp + "\r\n";
}
}
}catch (IOException e) {
e.printStackTrace();
}finally{
try{
if(br != null){
br.close();
}
}catch(Exception exx){
}
}

return code;
}

------解决方案--------------------
while ((str = reader.readLine()) != null) 这里改成while ((str = reader.readLine()) != "")
你试试行不?
阅读