]> WPIA git - gigi.git/commitdiff
upd: minor fixup on highFinancialValue code
authorFelix Dörre <felix@dogcraft.de>
Thu, 7 Jul 2016 07:02:45 +0000 (09:02 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 7 Jul 2016 07:02:45 +0000 (09:02 +0200)
Change-Id: I77914e4705371f0980bf9592bb506f033a881505

config/gigi.properties.template
util/org/cacert/gigi/util/HighFinancialValueFetcher.java

index a6406a1e0784d3a2608cc5644ee6bb310462c97d..c34fff171d72835e6e36c5c7f2ec9f4384899524 100644 (file)
@@ -15,4 +15,4 @@ sql.url=jdbc:postgresql://localhost/cacert
 sql.user=
 sql.password=
 
-highFinancialValue=/path/to/alexa/list
\ No newline at end of file
+highFinancialValue=/path/to/alexa/list
index c05c7ca608973dff13ffbf5e55b9183b2b2fbb7b..338b8ae2e324c68285c7c81dcc74dafeba221295 100644 (file)
@@ -16,26 +16,25 @@ public class HighFinancialValueFetcher {
         if (args.length > 1) {
             max = Integer.parseInt(args[1]);
         }
-        PrintWriter fos = new PrintWriter(new File(args[0]), "UTF-8");
-        ZipInputStream zis = new ZipInputStream(new URL("https://s3.amazonaws.com/alexa-static/top-1m.csv.zip").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) {
-                String[] parts = line.split(",");
-                int i = Integer.parseInt(parts[0]);
-                if (i > max) {
-                    zis.close();
-                    break outer;
+        try (PrintWriter fos = new PrintWriter(new File(args[0]), "UTF-8"); ZipInputStream zis = new ZipInputStream(new URL("https://s3.amazonaws.com/alexa-static/top-1m.csv.zip").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) {
+                    String[] parts = line.split(",");
+                    int i = Integer.parseInt(parts[0]);
+                    if (i > max) {
+                        zis.close();
+                        break outer;
+                    }
+                    fos.println(parts[1]);
+                    System.out.println(line);
                 }
-                fos.println(parts[1]);
-                System.out.println(line);
             }
         }
-        fos.close();
     }
 
 }