src/share/classes/java/util/Currency.java

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


 216                     scOldCurrenciesNumericCode = readIntArray(dis, scCount);
 217                     scNewCurrenciesNumericCode = readIntArray(dis, scCount);
 218                     int ocCount = dis.readInt();
 219                     otherCurrencies = dis.readUTF();
 220                     otherCurrenciesDFD = readIntArray(dis, ocCount);
 221                     otherCurrenciesNumericCode = readIntArray(dis, ocCount);
 222                     dis.close();
 223                 } catch (IOException e) {
 224                     InternalError ie = new InternalError();
 225                     ie.initCause(e);
 226                     throw ie;
 227                 }
 228 
 229                 // look for the properties file for overrides
 230                 try {
 231                     File propFile = new File(homeDir + File.separator +
 232                                              "lib" + File.separator +
 233                                              "currency.properties");
 234                     if (propFile.exists()) {
 235                         Properties props = new Properties();
 236                         props.load(new FileReader(propFile));


 237                         Set<String> keys = props.stringPropertyNames();
 238                         Pattern propertiesPattern =
 239                             Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
 240                         for (String key : keys) {
 241                            replaceCurrencyData(propertiesPattern,
 242                                key.toUpperCase(Locale.ROOT),
 243                                props.getProperty(key).toUpperCase(Locale.ROOT));
 244                         }
 245                     }
 246                 } catch (IOException e) {
 247                     info("currency.properties is ignored because of an IOException", e);
 248                 }
 249                 return null;
 250             }
 251         });
 252     }
 253 
 254     /**
 255      * Constants for retrieving localized names from the name providers.
 256      */




 216                     scOldCurrenciesNumericCode = readIntArray(dis, scCount);
 217                     scNewCurrenciesNumericCode = readIntArray(dis, scCount);
 218                     int ocCount = dis.readInt();
 219                     otherCurrencies = dis.readUTF();
 220                     otherCurrenciesDFD = readIntArray(dis, ocCount);
 221                     otherCurrenciesNumericCode = readIntArray(dis, ocCount);
 222                     dis.close();
 223                 } catch (IOException e) {
 224                     InternalError ie = new InternalError();
 225                     ie.initCause(e);
 226                     throw ie;
 227                 }
 228 
 229                 // look for the properties file for overrides
 230                 try {
 231                     File propFile = new File(homeDir + File.separator +
 232                                              "lib" + File.separator +
 233                                              "currency.properties");
 234                     if (propFile.exists()) {
 235                         Properties props = new Properties();
 236                         try (FileReader fr = new FileReader(propFile)) {
 237                             props.load(fr);
 238                         }
 239                         Set<String> keys = props.stringPropertyNames();
 240                         Pattern propertiesPattern =
 241                             Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
 242                         for (String key : keys) {
 243                            replaceCurrencyData(propertiesPattern,
 244                                key.toUpperCase(Locale.ROOT),
 245                                props.getProperty(key).toUpperCase(Locale.ROOT));
 246                         }
 247                     }
 248                 } catch (IOException e) {
 249                     info("currency.properties is ignored because of an IOException", e);
 250                 }
 251                 return null;
 252             }
 253         });
 254     }
 255 
 256     /**
 257      * Constants for retrieving localized names from the name providers.
 258      */