Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // Copyright 2007, 2008, 2010 The Apache Software Foundation
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry5.util;
public class TextStreamResponse implements StreamResponse
    private final ContentType contentType;
    private final String text;

Constructor that defaults the character set to "utf-8".
    public TextStreamResponse(String contentTypeString text)

Constructor allowing the content type and character set to the specified.

contentType type of content, often "text/xml"
charset character set of output, usually "UTF-8"
text text to be streamed in the response
See also:
    public TextStreamResponse(String contentTypeString charsetString text)
        this(new ContentType(contentTypecharset), text);
    public TextStreamResponse(ContentType contentTypeString text)
        assert contentType != null;
        assert text != null;
        this. = contentType;
        this. = text;
    public String getContentType()
        return .toString();

Converts the text to a byte array (as per the character set, which is usually "UTF-8"), and returns a stream for that byte array.

the text as a byte array stram
    public InputStream getStream() throws IOException
        byte[] textBytes = .getBytes(.getCharset());
        return new ByteArrayInputStream(textBytes);

Does nothing; subclasses may override.
    public void prepareResponse(Response response)
New to GrepCode? Check out our FAQ X