]> WPIA git - gigi.git/blob - util/org/cacert/gigi/util/HighFinancialValueFetcher.java
add: high financial value assessment
[gigi.git] / util / org / cacert / gigi / util / HighFinancialValueFetcher.java
1 package org.cacert.gigi.util;
2
3 import java.io.BufferedReader;
4 import java.io.File;
5 import java.io.IOException;
6 import java.io.InputStreamReader;
7 import java.io.PrintWriter;
8 import java.net.URL;
9 import java.util.zip.ZipEntry;
10 import java.util.zip.ZipInputStream;
11
12 public class HighFinancialValueFetcher {
13
14     public static void main(String[] args) throws IOException {
15         int max = 1000;
16         if (args.length > 1) {
17             max = Integer.parseInt(args[1]);
18         }
19         PrintWriter fos = new PrintWriter(new File(args[0]), "UTF-8");
20         ZipInputStream zis = new ZipInputStream(new URL("https://s3.amazonaws.com/alexa-static/top-1m.csv.zip").openStream());
21         ZipEntry ze;
22         outer:
23         while ((ze = zis.getNextEntry()) != null) {
24             System.out.println(ze.getName());
25             BufferedReader br = new BufferedReader(new InputStreamReader(zis, "UTF-8"));
26             String line;
27             while ((line = br.readLine()) != null) {
28                 String[] parts = line.split(",");
29                 int i = Integer.parseInt(parts[0]);
30                 if (i > max) {
31                     zis.close();
32                     break outer;
33                 }
34                 fos.println(parts[1]);
35                 System.out.println(line);
36             }
37         }
38         fos.close();
39     }
40
41 }