public class GetUrl{
public static String getUrl(String content)throws IOException{
URL server=new URL("http://hanyu.iciba.com/hanzi/+i+shtml");
URLConnection connection=server.openConnection();
connection.connect(); //连接网页
InputStream in=connection.getInputStream();
BufferedReader reader =new BufferedReader(new InputStreamReader(in));
while((content=reader.readLine())!=null){
Append(content);
}
in.close();
return content;
}
public static void Append(String content) {
// TODO Auto-generated method stub
content+=content;
}
public static void main(String args[])
{
try {
getUrl(args);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
用java编写网络爬虫小程序,第一步获取网页的URL,将它存放在一个字符串中,可是这个需要怎样编写获取多个url呢? 总是出错。。