public String readFileContent(URL sUrl){
String sContent="";
String sCurrentLine;
sCurrentLine = "";
java.io.InputStream urlStream;
StringBuffer sb=new StringBuffer();
try {
//java.net.HttpURLConnection connection = (java.net.HttpURLConnection) sUrl.openConnection();
//connection.connect();
//urlStream = connection.getInputStream();
urlStream=sUrl.openStream();
//java.io.DataInputStream reader = new java.io.DataInputStream(new java.io.DataInputStream(urlStream));
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
//sTotalString +="\r\n"+sCurrentLine;
}
sContent=sb.toString();
reader.close();
urlStream.close();
} catch (IOException e) {
}
return sContent;
}
8 个解决方案
#1
public String readFileContent(URL sUrl){
String sContent="";
String sCurrentLine;
sCurrentLine = "";
java.io.InputStream urlStream;
StringBuffer sb=new StringBuffer();
try {
urlStream=sUrl.openStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
sContent=sb.toString();
reader.close();
urlStream.close();
} catch (IOException e) {
}
return sContent;
}
String sContent="";
String sCurrentLine;
sCurrentLine = "";
java.io.InputStream urlStream;
StringBuffer sb=new StringBuffer();
try {
urlStream=sUrl.openStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
sContent=sb.toString();
reader.close();
urlStream.close();
} catch (IOException e) {
}
return sContent;
}
#2
网络问题?
之前自己些的一个批量抓图下来的程序,也出现过抓下来的图片无法显示的问题,后来查出来是由于网络不稳定造成的,而且我这里设定了一个抓取时间,过了时间就跳过这图,去抓下一个,这时候没有抓完的那张图就无法打开了
从二进制流的方面来说,和楼主的现象应该是一致的
之前自己些的一个批量抓图下来的程序,也出现过抓下来的图片无法显示的问题,后来查出来是由于网络不稳定造成的,而且我这里设定了一个抓取时间,过了时间就跳过这图,去抓下一个,这时候没有抓完的那张图就无法打开了
从二进制流的方面来说,和楼主的现象应该是一致的
#3
程序上我觉得应该没什么问题 因为如果有问题的话 所有的静态页面都生成不了了
至于yibunengjing 所说的网络问题,我太确定 读的网页实际上都是本地的地址
郁闷 搞了好几天了 也没搞出个所以然来
至于yibunengjing 所说的网络问题,我太确定 读的网页实际上都是本地的地址
郁闷 搞了好几天了 也没搞出个所以然来
#4
咋就没人帮看看呢?1
#5
还有一个问题啊:
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Shutting down 'converse' pool immediately [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Waiting until Mon Mar 10 10:55:49 YAPT 2008 for all connections to become inactive (active count is 5).
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
警告: Shutdown waited for 2 milliseconds for all the connections to become inactive but the active count is still 5. Shutting down anyway.
2008-3-10 10:55:49 org.logicalcobwebs.proxool.PrototyperController shutdown
信息: Stopping Prototyper thread
2008-3-10 10:55:49 org.logicalcobwebs.proxool.HouseKeeperController shutdown
信息: Stopping HouseKeeper thread
2008-3-10 10:55:49 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:50 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:51 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:52 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:53 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:54 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:55 org.logicalcobwebs.proxool.ProxoolFacade registerConnectionPool
信息: Proxool 0.9.0RC3 (10-Jan-2007 01:38)
不知道是啥原因
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Shutting down 'converse' pool immediately [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Waiting until Mon Mar 10 10:55:49 YAPT 2008 for all connections to become inactive (active count is 5).
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
警告: Shutdown waited for 2 milliseconds for all the connections to become inactive but the active count is still 5. Shutting down anyway.
2008-3-10 10:55:49 org.logicalcobwebs.proxool.PrototyperController shutdown
信息: Stopping Prototyper thread
2008-3-10 10:55:49 org.logicalcobwebs.proxool.HouseKeeperController shutdown
信息: Stopping HouseKeeper thread
2008-3-10 10:55:49 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:50 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:51 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:52 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:53 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:54 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:55 org.logicalcobwebs.proxool.ProxoolFacade registerConnectionPool
信息: Proxool 0.9.0RC3 (10-Jan-2007 01:38)
不知道是啥原因
#6
代码改了下:
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) sUrl.openConnection();
connection.setConnectTimeout(30000); //加了这么两个超时设置
connection.setReadTimeout(30000);
connection.connect();
urlStream = connection.getInputStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
reader.close();
urlStream.close();
到目前为止没有再生成一半的情况 再观察!!
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) sUrl.openConnection();
connection.setConnectTimeout(30000); //加了这么两个超时设置
connection.setReadTimeout(30000);
connection.connect();
urlStream = connection.getInputStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
reader.close();
urlStream.close();
到目前为止没有再生成一半的情况 再观察!!
#7
后来发现 读写的问题了 因为本身的JSP页面的问题:
访问JSP页面时它本身就显示不全
这样当然就造成了静态页面的不全了
但是JSP页面中的代码是完整的,不明白为什么JSP页面只显示一半,而且还是间歇性无规律性
郁闷
#8
问题解决:显示有些时候显示一半是因为页面中有空指针异常
#1
public String readFileContent(URL sUrl){
String sContent="";
String sCurrentLine;
sCurrentLine = "";
java.io.InputStream urlStream;
StringBuffer sb=new StringBuffer();
try {
urlStream=sUrl.openStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
sContent=sb.toString();
reader.close();
urlStream.close();
} catch (IOException e) {
}
return sContent;
}
String sContent="";
String sCurrentLine;
sCurrentLine = "";
java.io.InputStream urlStream;
StringBuffer sb=new StringBuffer();
try {
urlStream=sUrl.openStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
sContent=sb.toString();
reader.close();
urlStream.close();
} catch (IOException e) {
}
return sContent;
}
#2
网络问题?
之前自己些的一个批量抓图下来的程序,也出现过抓下来的图片无法显示的问题,后来查出来是由于网络不稳定造成的,而且我这里设定了一个抓取时间,过了时间就跳过这图,去抓下一个,这时候没有抓完的那张图就无法打开了
从二进制流的方面来说,和楼主的现象应该是一致的
之前自己些的一个批量抓图下来的程序,也出现过抓下来的图片无法显示的问题,后来查出来是由于网络不稳定造成的,而且我这里设定了一个抓取时间,过了时间就跳过这图,去抓下一个,这时候没有抓完的那张图就无法打开了
从二进制流的方面来说,和楼主的现象应该是一致的
#3
程序上我觉得应该没什么问题 因为如果有问题的话 所有的静态页面都生成不了了
至于yibunengjing 所说的网络问题,我太确定 读的网页实际上都是本地的地址
郁闷 搞了好几天了 也没搞出个所以然来
至于yibunengjing 所说的网络问题,我太确定 读的网页实际上都是本地的地址
郁闷 搞了好几天了 也没搞出个所以然来
#4
咋就没人帮看看呢?1
#5
还有一个问题啊:
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Shutting down 'converse' pool immediately [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Waiting until Mon Mar 10 10:55:49 YAPT 2008 for all connections to become inactive (active count is 5).
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
警告: Shutdown waited for 2 milliseconds for all the connections to become inactive but the active count is still 5. Shutting down anyway.
2008-3-10 10:55:49 org.logicalcobwebs.proxool.PrototyperController shutdown
信息: Stopping Prototyper thread
2008-3-10 10:55:49 org.logicalcobwebs.proxool.HouseKeeperController shutdown
信息: Stopping HouseKeeper thread
2008-3-10 10:55:49 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:50 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:51 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:52 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:53 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:54 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:55 org.logicalcobwebs.proxool.ProxoolFacade registerConnectionPool
信息: Proxool 0.9.0RC3 (10-Jan-2007 01:38)
不知道是啥原因
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Shutting down 'converse' pool immediately [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
信息: Waiting until Mon Mar 10 10:55:49 YAPT 2008 for all connections to become inactive (active count is 5).
2008-3-10 10:55:49 org.logicalcobwebs.proxool.ConnectionPool shutdown
警告: Shutdown waited for 2 milliseconds for all the connections to become inactive but the active count is still 5. Shutting down anyway.
2008-3-10 10:55:49 org.logicalcobwebs.proxool.PrototyperController shutdown
信息: Stopping Prototyper thread
2008-3-10 10:55:49 org.logicalcobwebs.proxool.HouseKeeperController shutdown
信息: Stopping HouseKeeper thread
2008-3-10 10:55:49 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:50 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:51 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 11 instance(s) to be deallocated
2008-3-10 10:55:52 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:53 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:54 org.apache.catalina.core.StandardWrapper unload
信息: Waiting for 91 instance(s) to be deallocated
2008-3-10 10:55:55 org.logicalcobwebs.proxool.ProxoolFacade registerConnectionPool
信息: Proxool 0.9.0RC3 (10-Jan-2007 01:38)
不知道是啥原因
#6
代码改了下:
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) sUrl.openConnection();
connection.setConnectTimeout(30000); //加了这么两个超时设置
connection.setReadTimeout(30000);
connection.connect();
urlStream = connection.getInputStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
reader.close();
urlStream.close();
到目前为止没有再生成一半的情况 再观察!!
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) sUrl.openConnection();
connection.setConnectTimeout(30000); //加了这么两个超时设置
connection.setReadTimeout(30000);
connection.connect();
urlStream = connection.getInputStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(urlStream));
while ((sCurrentLine = reader.readLine()) != null){
sb.append(sCurrentLine).append("\r\n");
}
reader.close();
urlStream.close();
到目前为止没有再生成一半的情况 再观察!!
#7
后来发现 读写的问题了 因为本身的JSP页面的问题:
访问JSP页面时它本身就显示不全
这样当然就造成了静态页面的不全了
但是JSP页面中的代码是完整的,不明白为什么JSP页面只显示一半,而且还是间歇性无规律性
郁闷
#8
问题解决:显示有些时候显示一半是因为页面中有空指针异常