Class FormatDetector

java.lang.Object
com.electronwill.nightconfig.core.file.FormatDetector

public final class FormatDetector extends Object
Utility class for detecting the format of configurations files.
  • Method Details

    • registerExtension

      public static void registerExtension(String fileExtension, ConfigFormat<?> format)
      Registers a ConfigFormat for a specific fileExtension.
      Parameters:
      fileExtension - the file extension
      format - the config format
    • registerExtension

      public static void registerExtension(String fileExtension, Supplier<ConfigFormat<?>> formatSupplier)
      Registers a ConfigFormat's supplier for a specific fileExtension.
      Parameters:
      fileExtension - the file extension
      formatSupplier - the Supplier of the config format
    • detect

      public static ConfigFormat<?> detect(File file)
      Detects the ConfigFormat of a file.
      Parameters:
      file - the file
      Returns:
      the associated ConfigFormat, or null if not found
    • detect

      public static ConfigFormat<?> detect(Path file)
      Detects the ConfigFormat of a file.
      Parameters:
      file - the file
      Returns:
      the associated ConfigFormat, or null if not found
    • detectByName

      public static ConfigFormat<?> detectByName(String fileName)
      Detects the ConfigFormat of a filename.
      Parameters:
      fileName - the file name
      Returns:
      the associated ConfigFormat, or null if not found