From: Felix Dörre Date: Thu, 7 Jul 2016 07:02:45 +0000 (+0200) Subject: upd: minor fixup on highFinancialValue code X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=41475d570b891d2af3a541298fd89a4c0dfb4ab5;hp=258fed97058e563788f5b598097daa880921e500 upd: minor fixup on highFinancialValue code Change-Id: I77914e4705371f0980bf9592bb506f033a881505 --- diff --git a/config/gigi.properties.template b/config/gigi.properties.template index a6406a1e..c34fff17 100644 --- a/config/gigi.properties.template +++ b/config/gigi.properties.template @@ -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 diff --git a/util/org/cacert/gigi/util/HighFinancialValueFetcher.java b/util/org/cacert/gigi/util/HighFinancialValueFetcher.java index c05c7ca6..338b8ae2 100644 --- a/util/org/cacert/gigi/util/HighFinancialValueFetcher.java +++ b/util/org/cacert/gigi/util/HighFinancialValueFetcher.java @@ -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(); } }