Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;

public class Main {

    public static void main(String[] args) {
        ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US);
        Enumeration<String> keys = bundle.getKeys();
        ArrayList<String> temp = new ArrayList<String>();

        for (Enumeration<String> e = keys; keys.hasMoreElements();) {
            String key = e.nextElement();
            if (key.startsWith("java2s")) {
                temp.add(key);
            }
        }

        String[] result = new String[temp.size()];

        for (int i = 0; i < temp.size(); i++) {
            result[i] = bundle.getString(temp.get(i));
        }
        System.out.println(Arrays.toString(result));
    }
}