Class File.Builder

java.lang.Object
com.teamdev.jxbrowser.net.File.Builder
Enclosing interface:
File

public static final class File.Builder extends Object
A builder of File.

Builders are created by invoking File.newBuilder(). Each of the setter methods modifies the state of the builder and returns the same instance. Builders are not thread-safe and should not be used concurrently from multiple threads without external synchronization.

  • Method Details

    • name

      public File.Builder name(String name)
      Sets the file name.
      Parameters:
      name - the file name
      Returns:
      this builder
    • contentType

      public File.Builder contentType(String contentType)
      Sets the file content type.

      Please note, when the file value is specified using a path, the content type may be omitted. In such cases, Chromium will automatically determine the content type based on the file extension. If no MIME type is associated with the extension, the content type defaults to application/octet-stream.

      For files provided as byte arrays, the content type is always passed as-is. It will not be determined automatically if it is empty.

      Parameters:
      contentType - the file content type determined by the file extension
      Returns:
      this builder
    • pathValue

      public File.Builder pathValue(Path path)
      Sets the file path.
      Parameters:
      path - the file path
      Returns:
      this builder
    • bytesValue

      public File.Builder bytesValue(byte[] bytes)
      Sets the file content.
      Parameters:
      bytes - the file content
      Returns:
      this builder
    • build

      public File build()
      Returns a new File instance built from the current state of this builder.
      Returns:
      a new File instance