Mega Code Archive

 
Categories / Java / Reflection
 

Returns the package portion of the specified class

public class Utils {   /**    * Returns the package portion of the specified class    * @param className the name of the class from which to extract the package    * @return package portion of the specified class    */   public static String getPackageName(final String className) {       if (className != null) {           final int index = className.lastIndexOf('.');           return ((index != -1) ? className.substring(0, index) : ""); // NOI18N       }       return null;   } }