Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static final List<String> getListFromBundle(ResourceBundle rb, String prefix) {
        String name = null;
        List<String> ret = new LinkedList<String>();
        Enumeration<String> names = rb.getKeys();
        while (names.hasMoreElements()) {
            name = names.nextElement();
            if (name != null && name.startsWith(prefix) && isInteger(name.substring(name.length() - 1))) {
                ret.add(rb.getString(name));
            }
        }
        Collections.sort(ret);
        return ret;
    }

    public static boolean isInteger(String substring) {
        try {
            Integer.parseInt(substring);
            return true;
        } catch (RuntimeException e) {
            return false;
        }
    }
}