java读取URL 返回XML 文件1M 浏览器直接打开5秒钟 使用下面代码 却要50多秒 求大神指导 java读取URL 返回1M 的 XML文件浏览器直接打开5秒钟 使用代码 却要50多秒 求大神指导 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看是不是HttpClientSSL.getContent1这个方法里有太慢的写法。 deubg 看在什么地方卡了。 就知道那步问题了 String url="####################";URLConnection uc=null; InputStream in=null; InputStreamReader rd=null; List<MatchInfo> mList1 = new ArrayList<MatchInfo>();try {Date stratDate = new Date();uc = new URL(url).openConnection();uc.setConnectTimeout(10000);uc.setDoOutput(true);in = new BufferedInputStream(uc.getInputStream());rd = new InputStreamReader(in, "UTF-8");java.io.BufferedReader br = new java.io.BufferedReader(rd);String tempbf;StringBuffer temp=new StringBuffer();while ((tempbf = br.readLine()) != null) {temp.append(tempbf);temp.append("\r\n");}//String content = HttpClientSSL.getContent1(url);System.out.println("抓取 结束" + " 耗时----"+ (stratDate.getTime() - new Date().getTime()) / 1000.0);这段被注释掉//String content = HttpClientSSL.getContent1(url); String content = HttpClientSSL.getContent1(url);这前后加个时间看看执行了多长时间。这之前的代码应该很快 uc = new URL(url).openConnection();应该是这里,因为网络的原因。 另外 初始化 StringBuffer/StringBuilder时传入一个足够的初始长度。 让屏幕开满玫瑰花 java命令行 问个byte数组的问题 jdbc的一个奇怪异常 小弟要毕业的矛盾,请大家给点见意我 关于函数调用问题 Runtime.getRuntime().exec问题 在Java Applet小应用程序里显示字符串? 初学者的疑惑,请各位赐教: 异常处理 如何获取当前时间,要求不带时分秒 上传视频技术架构? 我遇到一个Java中递归算法问题,有关生成数列的,求教
String url="####################";
URLConnection uc=null;
InputStream in=null;
InputStreamReader rd=null;
List<MatchInfo> mList1 = new ArrayList<MatchInfo>();
try {
Date stratDate = new Date();
uc = new URL(url).openConnection();
uc.setConnectTimeout(10000);
uc.setDoOutput(true);
in = new BufferedInputStream(uc.getInputStream());
rd = new InputStreamReader(in, "UTF-8");
java.io.BufferedReader br = new java.io.BufferedReader(rd);
String tempbf;
StringBuffer temp=new StringBuffer();
while ((tempbf = br.readLine()) != null) {
temp.append(tempbf);
temp.append("\r\n");
}
//String content = HttpClientSSL.getContent1(url);
System.out.println("抓取 结束" + " 耗时----"
+ (stratDate.getTime() - new Date().getTime()) / 1000.0);这段被注释掉//String content = HttpClientSSL.getContent1(url);
这前后加个时间看看执行了多长时间。这之前的代码应该很快
应该是这里,因为网络的原因。