Last active
December 16, 2015 16:09
-
-
Save meadhikari/5460813 to your computer and use it in GitHub Desktop.
ead Urls and I download web page content somewhere locally on HDD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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