]> WPIA git - gigi.git/blobdiff - util/org/cacert/gigi/util/HighFinancialValueFetcher.java
upd: minor fixup on highFinancialValue code
[gigi.git] / util / org / cacert / gigi / util / HighFinancialValueFetcher.java
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();
     }
 
 }