All Downloads are FREE. Search and download functionalities are using the official Maven repository.

yeamy.restlite.addition.TextPlainResponse Maven / Gradle / Ivy

The newest version!
package yeamy.restlite.addition;

import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

public class TextPlainResponse extends AbstractHttpResponse {

	public TextPlainResponse(Object txt) {
		this(200, txt);
	}

	public TextPlainResponse(int status, Object txt) {
		super(txt);
		setStatus(status);
		setContentType("text/plain");
	}

	@Override
	protected void writeContent(HttpServletResponse resp) throws IOException {
		try (PrintWriter w = resp.getWriter()) {
			w.write(String.valueOf(getData()));
		}
	}

}