Package penny.downloadmanager.control

Source Code of penny.downloadmanager.control.UrlGrabbers

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package penny.downloadmanager.control;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.lang.String;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
*
* @author john
*/
public class UrlGrabbers {

    public static List<URL> parseWhitespaceCommaFile(String filename) throws FileNotFoundException, MalformedURLException, IOException {
        List<URL> list = new ArrayList<URL>();
        LineNumberReader lr = new LineNumberReader(new BufferedReader(new FileReader(new File(filename))));
        String line = lr.readLine();
        while (line != null) {
            List<String> s = Arrays.asList(line.split("[\\s,]+"));
            for (String i : s) {
                try {
                    list.add(new URL(i));
                } catch(MalformedURLException ex) {
                   
                }
            }
            line = lr.readLine();
        }
        lr.close();
        return list;
    }
}
TOP

Related Classes of penny.downloadmanager.control.UrlGrabbers

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.