code: public static Style getStyleFromFile( File file ) {
          Style style = null;
          try {
              String name = file.getName();
              if (!name.endsWith("sld")) {
                  String nameWithoutExtention = FileUtilities.getNameWithoutExtention(file);
                  File sldFile = new File(file.getParentFile(), nameWithoutExtention + ".sld");
                  if (sldFile.exists()) {
                      file = sldFile;
                  } else {
                      // no style file here
                      return null;
                  }
              }
  
              SLDHandler h = new SLDHandler();
              StyledLayerDescriptor sld = h.parse(file, null, null, null);
  //            SLDParser stylereader = new SLDParser(sf, file);
  //            StyledLayerDescriptor sld = stylereader.parseSLD();
              style = getDefaultStyle(sld);
              return style;
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
      }
docs: Get the style from an sld file.
  
  @param file the SLD file or a companion file.
  @return the {@link Style} object.
  @throws IOException