Package com.puppycrawl.tadpole

Source Code of com.puppycrawl.tadpole.ConfigFactory

package com.puppycrawl.tadpole;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;

public class ConfigFactory {
    public Config load() throws FileNotFoundException {
        final List<String> feeds = new ArrayList<String>();
        final Reader r = new FileReader(new File("tadpole-config.txt"));
        try {
            final LineIterator iter = IOUtils.lineIterator(r);
            while (iter.hasNext()) {
                final String line = iter.nextLine().trim();
                if (!line.startsWith("#") && !line.isEmpty()) {
                    System.out.println("Using: " + line);
                    feeds.add(line);
                }
            }
        }
        finally {
            IOUtils.closeQuietly(r);
        }
        return new Config(feeds);
    }
}
TOP

Related Classes of com.puppycrawl.tadpole.ConfigFactory

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.