Guest User

Untitled

a guest
May 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package com;
  2.  
  3. import java.util.ResourceBundle;
  4. import java.util.StringTokenizer;
  5.  
  6. public class Bundle {
  7.    
  8.     private static final ResourceBundle bundle = ResourceBundle.getBundle("bundle");
  9.     private static final String delim = "${}";
  10.    
  11.     public static String property(String key) {
  12.         String msg = bundle.getString(key);
  13.         String prop = "";
  14.         String str;
  15.        
  16.         StringTokenizer stringTokenizer = new StringTokenizer(msg, delim, true);
  17.        
  18.         while(stringTokenizer.hasMoreTokens()) {
  19.             str = stringTokenizer.nextToken();
  20.             if(str.equals("$")) {
  21.                 stringTokenizer.nextToken();
  22.                 str = stringTokenizer.nextToken();
  23.                 prop += Bundle.property(str);
  24.                 stringTokenizer.nextToken();
  25.             } else {
  26.                 prop += str;
  27.             }
  28.         }
  29.        
  30.         return prop;
  31.     }
  32. }
Add Comment
Please, Sign In to add comment