Package jodd.io

Examples of jodd.io.FastCharArrayWriter


    if (contentLen != null) {
      contentLenValue = Integer.parseInt(contentLen);

      if (contentLenValue > 0) {
        FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter(contentLenValue);

        try {
          StreamUtil.copy(reader, fastCharArrayWriter, contentLenValue);
        } catch (IOException ioex) {
          throw new HttpException(ioex);
        }

        bodyString = fastCharArrayWriter.toString();
      }
    }

    // chunked encoding
    String transferEncoding = header("Transfer-Encoding");
    if (transferEncoding != null && transferEncoding.equalsIgnoreCase("chunked")) {

      FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter();
      try {
        while (true) {
          String line = reader.readLine();

          int len = Integer.parseInt(line, 16);

          if (len > 0) {
            StreamUtil.copy(reader, fastCharArrayWriter, len);
            reader.readLine();
          } else {
            // end reached, read trailing headers, if there is any
            readHeaders(reader);
            break;
          }
        }
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }

      bodyString = fastCharArrayWriter.toString();
    }

    // no body yet - special case
    if (bodyString == null && contentLenValue != 0) {
      // body ends when stream closes
      FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter();
      try {
        StreamUtil.copy(reader, fastCharArrayWriter);
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }
      bodyString = fastCharArrayWriter.toString();
    }

    // BODY READY - PARSE BODY
    String charset = this.charset;
    if (charset == null) {
View Full Code Here


    public void init(char[] content) {
      // create Lagarto
      lagartoParser = new LagartoParser(content, emitStrings);

      // prepare root tag writer
      fastCharArrayWriter = new FastCharArrayWriter();
      tagWriter = new TagWriter(fastCharArrayWriter);
    }
View Full Code Here

  public PrintWriter getWriter() {
    if (outWriter == null) {
      if (outStream != null) {
        throw new IllegalStateException("Can't call getWriter() after getOutputStream()");
      }
      bufferedWriter = new FastCharArrayWriter();
      outWriter = new PrintWriter(bufferedWriter) {
        @Override
        public void close() {
          // do not close the print writer after rendering
          // since it will remove reference to bufferedWriter
View Full Code Here

TOP

Related Classes of jodd.io.FastCharArrayWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.