Advertisement
Guest User

Untitled

a guest
Feb 15th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public static class UTF8Control extends Control {
  2.  
  3.         public UTF8Control() {
  4.  
  5.         }
  6.  
  7.         public ResourceBundle newBundle(File baseName, Locale locale)
  8.                 throws IllegalAccessException, InstantiationException, IOException {
  9.             String bundleName = toBundleName(baseName.getName(), locale);
  10.             String resourceName = toResourceName(bundleName, "properties");
  11.             ResourceBundle bundle = null;
  12.             InputStream stream = new FileInputStream(baseName);
  13.             try {
  14.                 // UTF-8.
  15.                 bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
  16.             } finally {
  17.                 stream.close();
  18.             }
  19.             return bundle;
  20.         }
  21.  
  22.     }
  23.  
  24. CALLED BY:
  25.  
  26. UTF8Control control = new UTF8Control();
  27. ResourceBundle en = control.newBundle(File, Locale.ENGLISH);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement