code: public static StyleWrapper createStyleFromGraphic( File graphicsPath ) throws IOException {
          String name = graphicsPath.getName();
          ExternalGraphic exGraphic = null;
          if (name.toLowerCase().endsWith(".png")) {
              exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png");
          } else if (name.toLowerCase().endsWith(".svg")) {
              exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
          } else if (name.toLowerCase().endsWith(".sld")) {
              StyledLayerDescriptor sld = readStyle(graphicsPath);
              Style style = SldUtilities.getDefaultStyle(sld);
              return new StyleWrapper(style);
          }
  
          if (exGraphic == null) {
              throw new IOException("Style could not be created!");
          }
  
          Graphic gr = sf.createDefaultGraphic();
          gr.graphicalSymbols().clear();
          gr.graphicalSymbols().add(exGraphic);
          Expression size = ff.literal(20);
          gr.setSize(size);
  
          Rule rule = sf.createRule();
          PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null);
          rule.symbolizers().add(pointSymbolizer);
  
          FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle();
          featureTypeStyle.rules().add(rule);
  
          Style namedStyle = sf.createStyle();
          namedStyle.featureTypeStyles().add(featureTypeStyle);
          namedStyle.setName(FilenameUtils.removeExtension(name));
  
          return new StyleWrapper(namedStyle);
      }
docs: Generates a style based on a graphic.
  
  @param graphicsPath the graphic.
  @return the generated style.
  @throws IOException