code: @Nonnull
    public static String extractPackageName(@Nonnull final String fileNameWithoutExtension) {
      final int lastDot = fileNameWithoutExtension.lastIndexOf('.');
      if (lastDot < 0) {
        return "";
      }
      return fileNameWithoutExtension.substring(0, lastDot).trim();
    }
docs: Extract package name from canonical Java class name
  
  @param fileNameWithoutExtension canonical class name (like 'a.b.c.SomeClassName'), must not be null
  @return extracted package name, must not be null but can be empty