Class FileHandler

java.lang.Object
dev.katsute.simplehttpserver.handler.file.FileHandler
All Implemented Interfaces:
HttpHandler, SimpleHttpHandler

public class FileHandler extends Object implements SimpleHttpHandler
A file handler can be used to serve single or multiple files on a server with optional pre/post processing using FileAdapters.

FileAdapter

A FileAdapter determines where a file can be accessed and what content it will return. By default files would be accessible at the file name (including extension) with the file content.

Adding Files

The name parameters in the add methods supersedes the FileAdapter and makes a file accessible at whatever name you set.

FileOptions

File options can be added to influence the behavior of added files.

Context

The FileOptions.context property determines at where the file will be located with respect to the file handler. By default this is "" and any added files will be accessible directly after the file handler's context.
Example: /fileHandlerContext/file.txt by default and /fileHandlerContext/optionsContext/file.txt if a context was set.

Loading Options

The FileOptions.loading option determines how a file should be loaded when added.

Cache

If the loading option FileOptions.FileLoadingOption.CACHE is used, the FileOptions.cache determines how long to cache files for in milliseconds.

Walk

When directories are added, if true, will also include subdirectories; if false, will only include files in the immediate directory.
Since:
5.0.0
Version:
5.0.0
Author:
Katsute
See Also: