lol...This is actually a PHP forum.
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");
}
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community