Class DotenvBuilder

java.lang.Object
io.github.cdimascio.dotenv.DotenvBuilder

public class DotenvBuilder
extends Object
Builds and loads and Dotenv instance.
See Also:
Dotenv.configure()
  • Constructor Details

    • DotenvBuilder

      public DotenvBuilder()
  • Method Details

    • directory

      public DotenvBuilder directory​(String path)
      Sets the directory containing the .env file.
      Parameters:
      path - the directory containing the .env file
      Returns:
      this DotenvBuilder
    • filename

      public DotenvBuilder filename​(String name)
      Sets the name of the .env file. The default is .env.
      Parameters:
      name - the filename
      Returns:
      this DotenvBuilder
    • ignoreIfMissing

      public DotenvBuilder ignoreIfMissing()
      Does not throw an exception when .env is missing.
      Returns:
      this DotenvBuilder
    • ignoreIfMalformed

      public DotenvBuilder ignoreIfMalformed()
      Does not throw an exception when .env is malformed.
      Returns:
      this DotenvBuilder
    • systemProperties

      public DotenvBuilder systemProperties()
      Sets each environment variable as system properties.
      Returns:
      this DotenvBuilder
    • load

      public Dotenv load() throws DotenvException
      Load the contents of .env into the virtual environment.
      Returns:
      a new Dotenv instance
      Throws:
      DotenvException - when an error occurs