john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

urlsnatch.java

//my url download work
//John Pfeiffer

import java.net.*;
import java.io.*;

public class urlsnatch
{

    public static void main(String[] args) throws Exception
    {
        String inputLine;
        String webaddress;
        String outfilename;
        URL tempurl;
        PrintWriter fout = null;
        BufferedReader in = null;

        BufferedReader fin = new BufferedReader(new FileReader("mylist.txt"));

        webaddress = fin.readLine();

        while( webaddress !=  null)
        {

            outfilename = webaddress;
            System.out.println("getting " + outfilename);
            fout = new PrintWriter(new BufferedWriter(new FileWriter(outfilename)));

            webaddress = "http://" + webaddress;

            tempurl = new URL(webaddress);
            System.out.println("downloading website...");
            in = new BufferedReader(new InputStreamReader(tempurl.openStream()));

            System.out.println("writing to file...");
            while ((inputLine = in.readLine()) != null)
            {
                fout.write(inputLine);
            }

            webaddress = fin.readLine();

        }
        System.out.println("done");

        in.close();     //closes url socket
        fin.close();    //closes website download list file channel
        fout.close();   //closes html output file channel
    }
}

  • « iphone4 itunes u playlist bug workaround
  • firefox manually migrate passwords sqlite »

Published

Dec 13, 2010

Category

java

~93 words

Tags

  • java 252
  • urlsnatch.java 1