APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.net.httpserver.simpleserver

pack-priv final Class SimpleFileServerImpl

extends Object
Class Inheritance
Imports
com.sun.net.httpserver.HttpServer, .SimpleFileServer, .SimpleFileServer.OutputLevel, java.io.IOException, .PrintWriter, java.net.Inet6Address, .InetAddress, .InetSocketAddress, .UnknownHostException, java.nio.file.Files, .Path, java.util.Arrays, .Iterator, .Locale, .NoSuchElementException, .Objects

A class that provides a simple HTTP file server to serve the content of a given directory.

The server is an HttpServer bound to a given address. It comes with an HttpHandler that serves files from a given directory path (and its subdirectories) on the default file system, and an optional Filter that prints log messages related to the exchanges handled by the server to a given output stream.

Unless specified as arguments, the default values are:

  • port: 8000
  • The implementation is provided via the main entry point of the jdk.httpserver module.

    Nested and Inner Type Summary

    Modifier and TypeClass and Description
    private static class
    private static enum

    Field Summary

    Modifier and TypeField and Description
    private static boolean
    private static final SimpleFileServer.OutputLevel
    private static final int
    private static final Path
    private static final InetAddress

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

    Modifier and TypeMethod and Description
    private static Path
    realPath(Path root)

    pack-priv static int

    Returns:

    startup status code
    start
    (PrintWriter
    the writer to which output should be written
    writer
    ,
    String
    the launcher the server is started from
    launcher
    ,
    String[]
    the command line options
    args
    )

    Starts a simple HTTP file server created on a directory.

    Inherited from java.lang.Object:
    cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

    Field Detail

    addrSpecifiedback to summary
    private static boolean addrSpecified
    DEFAULT_OUTPUT_LEVELback to summary
    private static final SimpleFileServer.OutputLevel DEFAULT_OUTPUT_LEVEL
    DEFAULT_PORTback to summary
    private static final int DEFAULT_PORT
    DEFAULT_ROOTback to summary
    private static final Path DEFAULT_ROOT
    LOOPBACK_ADDRback to summary
    private static final InetAddress LOOPBACK_ADDR

    Constructor Detail

    SimpleFileServerImplback to summary
    private SimpleFileServerImpl()

    Method Detail

    realPathback to summary
    private static Path realPath(Path root)
    startback to summary
    pack-priv static int start(PrintWriter writer, String launcher, String[] args)

    Starts a simple HTTP file server created on a directory.

    Parameters
    writer:PrintWriter

    the writer to which output should be written

    launcher:String

    the launcher the server is started from

    args:String[]

    the command line options

    Returns:int

    startup status code

    Exceptions
    NullPointerException:
    if any of the arguments are null, or if there are any null values in the args array
    sun.net.httpserver.simpleserver back to summary

    private final Class SimpleFileServerImpl.Out

    extends Object
    Class Inheritance

    Field Summary

    Modifier and TypeField and Description
    private final PrintWriter

    Constructor Summary

    AccessConstructor and Description
    private
    Out()

    pack-priv
    Out(PrintWriter writer)

    Method Summary

    Modifier and TypeMethod and Description
    pack-priv void
    pack-priv void
    pack-priv void
    pack-priv void
    showHelp(String launcher)

    pack-priv void
    pack-priv void
    showUsage(String launcher)

    pack-priv void
    showVersion(String launcher)

    Inherited from java.lang.Object:
    cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

    Field Detail

    writerback to summary
    private final PrintWriter writer

    Constructor Detail

    Outback to summary
    private Out()
    Outback to summary
    pack-priv Out(PrintWriter writer)

    Method Detail

    flushback to summary
    pack-priv void flush()
    printStartMessageback to summary
    pack-priv void printStartMessage(Path root, HttpServer server) throws UnknownHostException
    reportErrorback to summary
    pack-priv void reportError(String message)
    showHelpback to summary
    pack-priv void showHelp(String launcher)
    showOptionback to summary
    pack-priv void showOption(String option)
    showUsageback to summary
    pack-priv void showUsage(String launcher)
    showVersionback to summary
    pack-priv void showVersion(String launcher)
    sun.net.httpserver.simpleserver back to summary

    private final Enum SimpleFileServerImpl.Startup

    extends Enum<SimpleFileServerImpl.Startup>
    Class Inheritance

    Field Summary

    Modifier and TypeField and Description
    public static final SimpleFileServerImpl.Startup
    CMDERR

    Not started, bad command-line arguments

    public static final SimpleFileServerImpl.Startup
    OK

    Started with no errors

    public final int
    public static final SimpleFileServerImpl.Startup
    SYSERR

    Not started, system error or resource exhaustion

    Constructor Summary

    AccessConstructor and Description
    private
    Startup(int statusCode)

    Method Summary

    Modifier and TypeMethod and Description
    public static SimpleFileServerImpl.Startup
    public static SimpleFileServerImpl.Startup[]
    Inherited from java.lang.Enum:
    clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

    Field Detail

    CMDERRback to summary
    public static final SimpleFileServerImpl.Startup CMDERR

    Not started, bad command-line arguments

    OKback to summary
    public static final SimpleFileServerImpl.Startup OK

    Started with no errors

    statusCodeback to summary
    public final int statusCode
    SYSERRback to summary
    public static final SimpleFileServerImpl.Startup SYSERR

    Not started, system error or resource exhaustion

    Constructor Detail

    Startupback to summary
    private Startup(int statusCode)

    Method Detail

    valueOfback to summary
    public static SimpleFileServerImpl.Startup valueOf(String name)
    valuesback to summary
    public static SimpleFileServerImpl.Startup[] values()