Package java.util

Examples of java.util.PropertyResourceBundle


     * Returns the message string with the specified key from the
     * "properties" file in the package containing the class with
     * the specified name.
     */
    protected static final String getString(String className, String resource_name, String key) {
        PropertyResourceBundle bundle = null;
        try {
            InputStream stream =
                Class.forName(className).getResourceAsStream(resource_name);
            bundle = new PropertyResourceBundle(stream);
        } catch(Throwable e) {
            throw new RuntimeException(e); // Chain the exception.
        }

        return (String)bundle.handleGetObject(key);
    }
View Full Code Here


  // We cannot really use this, since it breaks lazy loading. When resources for all locales
  // are in place it should be ok. Or we need another solution.
  //_resources = ResourceBundle.getBundle("jnlp/JreInstaller/resources/strings"); 
  try {
      URL bundle = (new Config()).getClass().getClassLoader().getResource("jnlp/sample/JreInstaller/resources/strings.properties")
      _resources = new PropertyResourceBundle(bundle.openStream());
  } catch(Throwable t) {
      Config.trace("Unable to load resources: " + t);
  }
    }
View Full Code Here

                        // is used to create a ResourceBundle. If either of the two previous steps for obtaining the
                        // ResourceBundle
                        // for this component is successful, the ResourceBundle is wrapped in a Map<String, String> and
                        // returned.
                        try {
                            _resourceBundleMap = new BundleMap(new PropertyResourceBundle(bundleResource.getInputStream()));
                        } catch (IOException e1) {
                            // Nothing happens, then resourceBundleMap is set as empty map
                        }
                    }
                }
View Full Code Here

                stream = loader.getResourceAsStream(resourceName);
            }

            if (stream != null) {
                try {
                    bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
                } finally {
                    stream.close();
                }
            }
View Full Code Here

    private PropertyResourceBundle getRAS(String res) throws Exception {
        InputStream ras = this.getClass().getResourceAsStream(res);
        if (ras == null){
            return null;
        }
        return new PropertyResourceBundle(ras);
    }
View Full Code Here

            if (defaultPRB == null){
                throw new IOException("Could not find required file: "+res);
            }
        } else if (checkUnexpected) {
            // Check all the keys are in the default props file
            PropertyResourceBundle prb = getRAS(res);
            if (prb == null){
                return;
            }
            final ArrayList<String> list = Collections.list(prb.getKeys());
            Collections.sort(list);
            final boolean mainResourceFile = resname.startsWith("messages");
            for (String key : list) {
                try {
                    String val = defaultPRB.getString(key); // Also Check key is in default
                    if (mainResourceFile && val.equals(prb.getString(key))){
                        System.out.println("Duplicate value? "+key+"="+val+" in "+res);
                        subTestFailures++;
                    }
                } catch (MissingResourceException e) {
                    subTestFailures++;
View Full Code Here

                        // for this component is successful, the ResourceBundle is wrapped in a Map<String, String> and
                        // returned.
                        try
                        {
                            _resourceBundleMap
                                    = new BundleMap(new PropertyResourceBundle(bundleResource.getInputStream()));
                        }
                        catch (IOException e1)
                        {
                            // Nothing happens, then resourceBundleMap is set as empty map
                        }
View Full Code Here

        else
        {
            // Try to read from specified properties file
            try
            {
                config = new PropertyResourceBundle(
                    new FileInputStream(configOverride));
            }
            catch (IOException e)
            {
                throw new ChainedRuntimeException(
View Full Code Here

        if (logConfig != null)
        {
            ResourceBundle bundle;
            try
            {
                bundle = new PropertyResourceBundle(
                    new FileInputStream(logConfig));
            }
            catch (IOException e)
            {
                throw new ChainedRuntimeException("Failed to load logging "
View Full Code Here

    Utf8PropertyResourceBundle(PropertyResourceBundle bundle) {
        this.bundle = bundle;
    }

    Utf8PropertyResourceBundle(InputStream inputStream) throws IOException {
        this.bundle = new PropertyResourceBundle(inputStream);
    }
View Full Code Here

TOP

Related Classes of java.util.PropertyResourceBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.