可以說我有一個網址列表,如如何處理一組url而不是每個url一次?
http://stackexchange.com
https://stackoverflow.com/users/login
http://careers.stackoverflow.com
http://chat.stackoverflow.com
http://meta.stackoverflow.com
https://stackoverflow.com/about
這個名單是在文本文件中。
現在我想一次性處理所有的網址。以下代碼是處理器。
String sourceUrlString="http://stackexchange.com";
if (args.length==0)
System.err.println("Using default argument of \""+sourceUrlString+'"');
else
sourceUrlString=args[0];
if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
Source source=new Source(new URL(sourceUrlString));
String renderedText=source.getRenderer().toString();
System.out.println("\nSimple rendering of the HTML document:\n");
System.out.println(renderedText);
正如你看到的,上面只有編碼可以在同一時間處理一個網址,讓我一定在sourceurlstring的URL手動密鑰。我如何一次處理文本文件中的所有網址?
做一個循環! – adarshr 2011-03-01 14:51:28
Loon - 在開始項目之前,您應該花一些時間學習基本的Java編程。 – 2011-03-01 15:01:55