Code example for PropertyResourceBundle

Methods: getString

0
        // TODO cache bundles 
        final String name = key.getClass().getName();
        final String fileName = name.replace('.', '/') + ".properties";
        String rez = null;
        try { 
            final ResourceBundle bundle = new PropertyResourceBundle(Bundle.class.getResourceAsStream("/" + fileName));
            try { 
                rez = bundle.getString(key.name());
            } 
            catch (MissingResourceException e) {
                LOG.warn("No key for " + key.name());
            } 
        } 
        catch (IOException e) {
            LOG.warn("IO error", e);
        } 
        return rez != null ? rez : "Message for " + key.name();
    } 
 
} 
Experience pair programming with AI  Get Codota for Java