Example usage for org.apache.commons.io.output StringBuilderWriter append

List of usage examples for org.apache.commons.io.output StringBuilderWriter append

Introduction

In this page you can find the example usage for org.apache.commons.io.output StringBuilderWriter append.

Prototype

@Override
public Writer append(CharSequence value) 

Source Link

Document

Append a character sequence to this Writer.

Usage

From source file:com.addthis.hydra.query.web.GoogleDriveAuthentication.java

/**
 * Send an HTML formatted error message.
 *//* w  w  w .  jav  a2  s  .  c  o m*/
private static void sendErrorMessage(ChannelHandlerContext ctx, String message) throws IOException {
    HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    response.headers().set(CONTENT_TYPE, "text/html; charset=utf-8");
    StringBuilderWriter writer = new StringBuilderWriter(50);
    writer.append("<html><head><title>Hydra Query Master</title></head><body>");
    writer.append("<h3>");
    writer.append(message);
    writer.append("</h3></body></html>");
    ByteBuf textResponse = ByteBufUtil.encodeString(ctx.alloc(), CharBuffer.wrap(writer.getBuilder()),
            CharsetUtil.UTF_8);
    HttpContent content = new DefaultHttpContent(textResponse);
    response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, textResponse.readableBytes());
    ctx.write(response);
    ctx.write(content);
    ChannelFuture lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
    lastContentFuture.addListener(ChannelFutureListener.CLOSE);
}

From source file:ezbake.amino.cli.Main.java

public String getJarName() {
    StringBuilderWriter stringBuilderWriter = new StringBuilderWriter();
    stringBuilderWriter.append("java -jar jarFilename ");
    cmdLineParser.printSingleLineUsage(stringBuilderWriter, null);
    return stringBuilderWriter.toString();
}