Package io.github.cdimascio.dotenv
Class DotenvBuilder
- java.lang.Object
-
- io.github.cdimascio.dotenv.DotenvBuilder
-
public class DotenvBuilder extends Object
Builds and loads andDotenvinstance.- See Also:
Dotenv.configure()
-
-
Constructor Summary
Constructors Constructor Description DotenvBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DotenvBuilderdirectory(String path)Sets the directory containing the .env file.DotenvBuilderfilename(String name)Sets the name of the .env file.DotenvBuilderignoreIfMalformed()Does not throw an exception when .env is malformed.DotenvBuilderignoreIfMissing()Does not throw an exception when .env is missing.Dotenvload()Load the contents of .env into the virtual environment.DotenvBuildersystemProperties()Sets each environment variable as system properties.
-
-
-
Method Detail
-
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
Dotenvinstance - Throws:
DotenvException- when an error occurs
-
-