]> WPIA git - gigi.git/blobdiff - util/org/cacert/gigi/util/FetchLocales.java
Fix: exceptional resource leaks.
[gigi.git] / util / org / cacert / gigi / util / FetchLocales.java
index 4c93021e9e38acf9f44e3ef947e2a885e27c9c8e..21a789f3342c8757f03e95d047123841ad744f6d 100644 (file)
@@ -3,6 +3,7 @@ package org.cacert.gigi.util;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Scanner;
@@ -34,7 +35,9 @@ public class FetchLocales {
     public static void main(String[] args) throws IOException, ParserConfigurationException, TransformerException {
         System.out.println("downloading locales ...");
         File locale = new File("locale");
-        locale.mkdir();
+        if ( !locale.mkdir()) {
+            throw new IOException("Could not create locales directory.");
+        }
 
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         DocumentBuilder db = dbf.newDocumentBuilder();
@@ -43,7 +46,7 @@ public class FetchLocales {
             doc.appendChild(doc.createElement("translations"));
             URL fetch = new URL(PO_URL_TEMPLATE.replace("%", lang));
             URLConnection uc = fetch.openConnection();
-            Scanner sc = new Scanner(uc.getInputStream());
+            Scanner sc = new Scanner(new InputStreamReader(uc.getInputStream(), "UTF-8"));
             String s = readLine(sc);
             StringBuffer contents = new StringBuffer();
             String id = "";