X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=util%2Forg%2Fcacert%2Fgigi%2Futil%2FHighFinancialValueFetcher.java;fp=util%2Forg%2Fcacert%2Fgigi%2Futil%2FHighFinancialValueFetcher.java;h=0000000000000000000000000000000000000000;hp=abac278dbd9ea05b5fd54e7cea067bb0696d18d5;hb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;hpb=c9ed09f0007fc2c813815be927a5a24b23dab83c diff --git a/util/org/cacert/gigi/util/HighFinancialValueFetcher.java b/util/org/cacert/gigi/util/HighFinancialValueFetcher.java deleted file mode 100644 index abac278d..00000000 --- a/util/org/cacert/gigi/util/HighFinancialValueFetcher.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.cacert.gigi.util; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.net.URL; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -public abstract class HighFinancialValueFetcher { - - public final int max; - - private File f; - - private String base; - - public HighFinancialValueFetcher(File f, int max, String base) { - this.f = f; - this.max = max; - this.base = base; - } - - public static void main(String[] args) throws IOException { - int max = 1000; - if (args.length > 1) { - max = Integer.parseInt(args[1]); - } - HighFinancialValueFetcher fetcher; - if (args.length > 2 && "--alexa".equals(args[2])) { - fetcher = new HighFinancialValueFetcherAlexa(new File(args[0]), max); - } else { - fetcher = new HighFinancialValueFetcherUmbrella(new File(args[0]), max); - } - fetcher.fetch(); - } - - public final void fetch() throws IOException { - try (PrintWriter fos = new PrintWriter(f, "UTF-8"); ZipInputStream zis = new ZipInputStream(new URL(base).openStream())) { - ZipEntry ze; - outer: - while ((ze = zis.getNextEntry()) != null) { - System.out.println(ze.getName()); - BufferedReader br = new BufferedReader(new InputStreamReader(zis, "UTF-8")); - String line; - while ((line = br.readLine()) != null) { - handle(line, fos); - if (entries == -1) { - break outer; - } - } - } - } - } - - private int entries; - - public void emit(PrintWriter fos, String value) { - fos.println(value); - if (entries == -1 || entries++ > max) { - entries = -1; - } - } - - public abstract void handle(String line, PrintWriter fos); -}