Skip to content

Instantly share code, notes, and snippets.

@meadhikari
Last active December 16, 2015 16:09
Show Gist options
  • Save meadhikari/5460813 to your computer and use it in GitHub Desktop.
Save meadhikari/5460813 to your computer and use it in GitHub Desktop.
ead Urls and I download web page content somewhere locally on HDD
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
public class Main {
public static void main(String argv[]) throws MalformedURLException, IOException
{
File file = new File("urllist.txt");
try {
Scanner scanner = new Scanner(file);
int i = 0;
while (scanner.hasNextLine()) {
String url = scanner.nextLine();
System.out.println(url);
String out = new Scanner(new URL(url).openStream(), "UTF-8").useDelimiter("\\A").next();
System.out.println(out);
PrintWriter lout = new PrintWriter("content_url"+ i+ ".txt");
i++;
lout.println(out);
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment