How to handle a set of URLs instead of one URL at a time?

says i have a list of urls like

http://stackexchange.com
https://stackoverflow.com/users/login
http://careers.stackoverflow.com
http://chat.stackoverflow.com
http://meta.stackoverflow.com
https: // stackoverflow .com / about

this list is in a text file.

Now, I would like to process all the URLs in one go. The processor is encoded below.

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);

as you can see, the above encoding can only process one url at a time when I have to manually enter the url in the sourceurlstring line. How to handle all urls in a text file at once?

+3
source share
2 answers
+3

Multithreading.

: Java

0

Source: https://habr.com/ru/post/1795513/


All Articles