code: public static String getFileExtension(String resource)
      {
          // E.g uf foo.bar.java.stg, it is the . before "java" 
          int secondToTheLastDot = resource.lastIndexOf('.', resource.length()-5);
          if(secondToTheLastDot == -1)
          {
              throw new IllegalArgumentException("The resource must be named like: 'foo.type.stg' " +
              		"where '.type' will be the file extension of the output files.");
          }
          String extension = resource.substring(secondToTheLastDot, resource.length()-4);
          // to protected against resources like "foo..stg"
          if(extension.length() < 2)
          {
              throw new IllegalArgumentException("The resource must be named like: 'foo.type.stg' " +
                          "where '.type' will be the file extension of the output files.");
          }
          
          return extension;
      }
docs: Get the file extension of the provided stg resource.