1 package club.wpia.gigi.util;
3 import java.io.BufferedReader;
5 import java.io.IOException;
6 import java.io.InputStreamReader;
7 import java.io.PrintWriter;
9 import java.util.zip.ZipEntry;
10 import java.util.zip.ZipInputStream;
12 public abstract class HighFinancialValueFetcher {
20 public HighFinancialValueFetcher(File f, int max, String base) {
26 public static void main(String[] args) throws IOException {
28 if (args.length > 1) {
29 max = Integer.parseInt(args[1]);
31 HighFinancialValueFetcher fetcher;
32 if (args.length > 2 && "--alexa".equals(args[2])) {
33 fetcher = new HighFinancialValueFetcherAlexa(new File(args[0]), max);
35 fetcher = new HighFinancialValueFetcherUmbrella(new File(args[0]), max);
40 public final void fetch() throws IOException {
41 try (PrintWriter fos = new PrintWriter(f, "UTF-8"); ZipInputStream zis = new ZipInputStream(new URL(base).openStream())) {
44 while ((ze = zis.getNextEntry()) != null) {
45 System.out.println(ze.getName());
46 BufferedReader br = new BufferedReader(new InputStreamReader(zis, "UTF-8"));
48 while ((line = br.readLine()) != null) {
60 public void emit(PrintWriter fos, String value) {
62 if (entries == -1 || entries++ > max) {
67 public abstract void handle(String line, PrintWriter fos);