浏览器访问一个网址秒出,用JAVA访问要等10秒以上,会是什么原因呢。
public static void main(String[] args) {
try {
URL oracle = new URL("https://item.rakuten.co.jp/soukaidrink/9000009984074/");
URLConnection yc = oracle.openConnection();
yc.connect();
List<String> lines = IOUtils.readLines(yc.getInputStream());
for (String line : lines) {
System.out.println(line);
}
}
catch (MalformedURLException e) {
// new URL() failed
// ...
}
catch (IOException e) {
// openConnection() failed
// ...
}
}
public static void main(String[] args) {
try {
URL oracle = new URL("https://item.rakuten.co.jp/soukaidrink/9000009984074/");
URLConnection yc = oracle.openConnection();
yc.connect();
List<String> lines = IOUtils.readLines(yc.getInputStream());
for (String line : lines) {
System.out.println(line);
}
}
catch (MalformedURLException e) {
// new URL() failed
// ...
}
catch (IOException e) {
// openConnection() failed
// ...
}
}