I’m trying to open multiple URL’s input streams, here’s my current code
FileInputStream fi = new FileInputStream("misc/links.txt");
DataInputStream in = new DataInputStream(fi);
BufferedReader read = new BufferedReader(new InputStreamReader(in));
String text;
while ((text = read.readLine()) != null) {
System.out.println (text+"?time=20");
URL url = new URL(text+"?time=20");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
}
I have all the links in the text file, line by line, and have PHP files that don’t show anything on the webpage for the specified seconds in the get method. Is there a way to just send the request and have the PHP do the rest, as this method goes through each link one by one waiting for a reply?
Without getting the response,
URLcannot submit the request. So the answer is NO.Instead , you can run each request in a seperate thread. If you do not want to create too many threads, you can use
ThreadPoolExecutor.