Source Code : Convert ResourceBundle to Properties

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Convert ResourceBundle to Properties

        

import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;

public class Main {
  public static void main(String[] args) {
    ResourceBundle resource = ResourceBundle.getBundle("Messages", Locale.UK);

    Properties properties = convertResourceBundleToProperties(resource);

    Enumeration keys = properties.keys();
    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      String value = (String) properties.get(key);
      System.out.println(key + " = " + value);
    }
  }

  static Properties convertResourceBundleToProperties(ResourceBundle resource) {
    Properties properties = new Properties();

    Enumeration<String> keys = resource.getKeys();
    while (keys.hasMoreElements()) {
      String key = keys.nextElement();
      properties.put(key, resource.getString(key));
    }

    return properties;
  }
}

   
    
    
    
    
    
    
    
  

Thank with us