Package jodd.io

Examples of jodd.io.FastCharArrayWriter


  /**
   * Loads properties from input stream. Stream is not closed at the end.
   */
  public void load(final InputStream in) throws IOException {
    final Writer out = new FastCharArrayWriter();
    StreamUtil.copy(in, out);
    parse(out.toString());
  }
View Full Code Here


  /**
   * Loads properties from input stream and provided encoding.
   * Stream is not closed at the end.
   */
  public void load(final InputStream in, final String encoding) throws IOException {
    final Writer out = new FastCharArrayWriter();
    StreamUtil.copy(in, out, encoding);
    parse(out.toString());
  }
View Full Code Here

    String contentLen = contentLength();
    if (contentLen != null) {
      int len = Integer.parseInt(contentLen);

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

        try {
          StreamUtil.copy(reader, fastCharArrayWriter, len);
        } 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) {
      // 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

  /**
   * Loads properties from input stream. Stream is not closed at the end.
   */
  public void load(final InputStream in) throws IOException {
    final Writer out = new FastCharArrayWriter();
    StreamUtil.copy(in, out);
    parse(out.toString());
  }
View Full Code Here

  /**
   * Loads properties from input stream and provided encoding.
   * Stream is not closed at the end.
   */
  public void load(final InputStream in, final String encoding) throws IOException {
    final Writer out = new FastCharArrayWriter();
    StreamUtil.copy(in, out, encoding);
    parse(out.toString());
  }
View Full Code Here

  protected String readDataFile(String fileName) throws IOException {
    String dataFolder = this.getClass().getPackage().getName() + ".data.";
    dataFolder = dataFolder.replace('.', '/');

    InputStream is = ClassLoaderUtil.getResourceAsStream(dataFolder + fileName);
    Writer out = new FastCharArrayWriter();
    String encoding = "UTF-8";
    if (fileName.endsWith(".properties")) {
      encoding = "ISO-8859-1";
    }
    StreamUtil.copy(is, out, encoding);
    StreamUtil.close(is);
    return out.toString();
  }
View Full Code Here

    StringBuilder stringBuilder = new StringBuilder();
    div.appendTextContent(stringBuilder);

    assertEquals(textContent, stringBuilder.toString());

    FastCharArrayWriter charBuffer = new FastCharArrayWriter();
    div.appendTextContent(charBuffer);

    assertEquals(textContent, charBuffer.toString());
  }
View Full Code Here

      char[] page = FileUtil.readString(file).toCharArray();

      String decoratorFileName = StringUtil.replace(file.getAbsolutePath(), ".html", "-decora.htm");
      char[] decorator = FileUtil.readString(decoratorFileName).toCharArray();

      FastCharArrayWriter writer = new FastCharArrayWriter();
      decoraParser.decorate(writer, page, decorator);
      String out = writer.toString();

      String outFileName = StringUtil.replace(file.getAbsolutePath(), ".html", "-out.htm");
      String outExpected = FileUtil.readString(outFileName);

      assertEquals(trimLines(outExpected), trimLines(out));
View Full Code Here

   * Returns buffered writer. Buffer will be created if not already used.
   */
  @Override
  public PrintWriter getWriter() {
    if (writer == null) {
      writer = new FastCharArrayWriter();
      printWriter = new PrintWriter(writer);
    }
    return printWriter;
  }
View Full Code Here

  /**
   * Renders tag body to char array.
   */
  public static char[] renderBody(JspFragment body) throws JspException {
    FastCharArrayWriter writer = new FastCharArrayWriter();
    invokeBody(body, writer);
    return writer.toCharArray();
  }
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.