1 22 package org.netbeans.lib.cvsclient.util; 23 24 import java.util.*; 25 26 30 public class BundleUtilities { 31 32 36 public static String getPackageName(Class clazz) { 37 String fullClassName = clazz.getName(); 38 int lastDotIndex = fullClassName.lastIndexOf('.'); 39 if (lastDotIndex < 0) { 40 return ""; } 42 return fullClassName.substring(0, lastDotIndex); 43 } 44 45 48 public static String getResourceName(Class classInSamePackage, String shortName) { 49 String packageName = getPackageName(classInSamePackage); 50 String resourceName = packageName.replace('.', '/') + '/' + shortName; 51 return resourceName; 52 } 53 54 57 public static ResourceBundle getResourceBundle(Class classInSamePackage, String shortName) { 58 String resourceName = getResourceName(classInSamePackage, shortName); 59 return ResourceBundle.getBundle(resourceName); 60 } 61 } 62 | Popular Tags |