Write the response to response body

Report a typo

What should be added instead of underscores to write Hello, World in an OutputStream as a response to the request?

public Headers handleGetRequest(HttpExchange exchange) throws IOException {
    String response = "Hello, World";
    exchange.sendResponseHeaders(200, response.getBytes().length);
    exchange.getResponseHeaders().set("Access-Control-Allow-Origin", "*");

    try (OutputStream stream = _________) {
        stream.write(response.getBytes());
    }

    return exchange.getResponseHeaders();
}
Enter a short text
___

Create a free account to access the full topic