user1563348
user1563348

Reputation: 81

StreamingOutput equivalent in Spring MVC

I have created a web application in spring boot in which I want to use Spring MVC rest framework instead of jersey. I am trying to do something like this but it gives me error. I want a equivalent of StreamingOutput in Spring MVC.

Ex: This uses JAX-RS StreamingOutput

public static StreamingOutput buildErrorEntity(Object error)
{
    StreamingOutput stream = outputStream -> {
        PrintStream printStream = new PrintStream(outputStream);
        new ObjectMapper().writeValue(printStream, error);
    };
    return stream;
}

I want to replace SteamingOutput but it gives me an error saying "Cannot resolve constructor PrintStream()

public static OutputStream buildErrorEntity1(Object error) {

    OutputStream stream = outputStream -> {
        PrintStream printStream = new PrintStream(outputStream);
        new ObjectMapper().writeValue(printStream, error);
    };

    return stream;
}

I would really appreciate some help. Thank you.

Upvotes: 7

Views: 4005

Answers (1)

Dmitry Zvorygin
Dmitry Zvorygin

Reputation: 477

They've added StreamingResponseBody in Spring 4.2.

Upvotes: 6

Related Questions