test/java/util/Currency/ValidateISO4217.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX

@@ -109,12 +109,13 @@
         }
     }
 
     static void test1() throws Exception {
 
-        FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
-        BufferedReader in = new BufferedReader(fr);
+        try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
+             BufferedReader in = new BufferedReader(fr))
+        {
         String line;
         SimpleDateFormat format = null;
 
         while ((line = in.readLine()) != null) {
             if (line.length() == 0 || line.charAt(0) == '#') {

@@ -159,11 +160,11 @@
             }
             int index = toIndex(country);
             testCountryCurrency(country, currency, Integer.parseInt(numeric),
                 Integer.parseInt(minorUnit), index);
         }
-        in.close();
+        }
 
         for (int i = 0; i < additionalCodes.length; i++) {
             int index = toIndex(additionalCodes[i][0]);
             if (additionalCodes[i][1].length() != 0) {
                 testCountryCurrency(additionalCodes[i][0], additionalCodes[i][1],