Support the ongoing development of Laravel.io →
Configuration Requests Database
Last updated 1 year ago.
0

lol...This is actually a PHP forum.

  • PS: This is not a complete solution.
  • PSS: This is untested code, so don't blame me if you get banned from sites :P
  • PSSS: You should program it concurrently using threads to increase efficiencies.
package com.company;

import java.io.IOException;
import java.net.*;
import java.util.*;

public class URLAccess {
    public List<String> urls;

    public static void main(String[] args) {
        URLAccess ua = new URLAccess();
        ua.run();
    }

    public URLAccess() {
        this.urls = new ArrayList<String>();
        // Read them from external XML or some other sources instead!
        this.urls.add("http://google.com");
        this.urls.add("http://alksdfjlaksjdflkajsdf.com");
    }

    public void run() {
        this.urls.forEach(this::accessUrl);
    }

    public void accessUrl(String urlString) {
        try {
            URL url = new URL(urlString);
            URLConnection urlConnection = url.openConnection();
            urlConnection.connect();
            System.out.println("Success");
        }
        catch (IOException ignored) {
            System.out.println("Failed");
        }
    }
}

0

Sign in to participate in this thread!

Eventy

Your banner here too?

manoj77 manoj77 Joined 26 Aug 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.