code: public static String getPackageName(Class<?> cls)
  	{
  		Package pkg;
  		String str;
  		int pos;
  
  		if(cls == null)
  			throw new NullPointerException("cls is null");
  		if((pkg = cls.getPackage())!=null)
  			return pkg.getName();
  		str = cls.getName();
  		if((pos = str.lastIndexOf('.'))>=0)
  			return str.substring(0,pos);
  		return "";	// default package
  	}
docs: Get the package name for a class.
  @param cls The class to get the package name for.
  @return the class's pacakge name.
  @throws NullPointerException if cls is null.