private void sendFile(HttpExchange request, String file)
    {
        String fullname = userdir + file;
        log.info("MiniThymeleafWebServer:sendFile - " + request.getRequestURI().toString() + " - " + fullname);

        File theFile = new File(fullname);

        if (theFile.exists())
        {
            MimeType theType = mimeTypeFactory.guessContentTypeFromName(file);

            byte[] fileContents = getFile(theFile);
            if (fileContents != null)
            {
                Headers responseHeaders = request.getResponseHeaders();
                responseHeaders.set("Date", new Date().toString());
                responseHeaders.set("Server", MTWS_TITLE);

                responseHeaders.set("Content-type", theType.getType());
                if (theType.isBinary())
                {
                    try
                    {
                        // Info on http://elliotth.blogspot.com/2009/03/using-comsunnethttpserver.html
                        responseHeaders.set("Content-Encoding", "gzip");
                        request.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0);  // Don't know how large the compressed file will be.
                        try (GZIPOutputStream gos = new GZIPOutputStream(request.getResponseBody(), BUFFER_MAX))
                        {
                            gos.write(fileContents);
                            gos.finish();
                            gos.close();
                        }
                        catch (Exception ex)
                        {
                            log.error("MiniThymeleafWebServer:sendFile - Binary file: " + file);
                            log.error("MiniThymeleafWebServer:sendFile()", ex);
                        }
                    }
                    catch (IOException ex)
                    {
                        log.error("MiniThymeleafWebServer:sendFile - Binary file: " + file);
                        log.error("MiniThymeleafWebServer:sendFile()", ex);
                    }
                }
                else
                {
                    try
                    {
                        request.sendResponseHeaders(HttpURLConnection.HTTP_OK, fileContents.length);
                        try (OutputStream os = request.getResponseBody())
                        {
                            os.write(fileContents);
                            os.flush();
                            os.close();
                        }
                        catch (Exception ex)
                        {
                            log.error("MiniThymeleafWebServer:sendFile - Text file: " + file);
                            log.error("MiniThymeleafWebServer:sendFile()", ex);
                        }
                    }
                    catch (IOException ex)
                    {
                        log.error("MiniThymeleafWebServer:sendFile - Text file: " + file);
                        log.error("MiniThymeleafWebServer:sendFile()", ex);
                    }
                }

                request.close();
            }
            else
            {
                // Code above has not got the file...
                try
                {
                    // File has no content.
                    request.sendResponseHeaders(HttpURLConnection.HTTP_NO_CONTENT, 0);
                    request.close();
                }
                catch (IOException ex)
                {
                    log.error("MiniThymeleafWebServer:sendFile - Sending response headers for file: " + file);
                    log.error("MiniThymeleafWebServer:sendFile()", ex);
                }

                log.warn("MiniThymeleafWebServer:sendFile - File '" + file + "' has no content.");
            }
        }
        else
        {
            // Code above has not got the file...
            try
            {
                // File does not exist.
                request.sendResponseHeaders(HttpURLConnection.HTTP_NOT_FOUND, 0);
                request.close();
            }
            catch (IOException ex)
            {
                log.error("MiniThymeleafWebServer:sendFile - Sending response headers for file: " + file);
                log.error("MiniThymeleafWebServer:sendFile()", ex);
            }

            log.info("File '" + file + "' not sent.");
        }
    }