Package java.io

Examples of java.io.StringWriter


    public String toXML() {
        return element.asXML();
    }

    public String toString() {
        StringWriter out = new StringWriter();
        XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint());
        try {
            writer.write(element);
        }
        catch (Exception e) {
            // Ignore.
        }
        return out.toString();
    }
View Full Code Here


    public String toXML() {
        return element.asXML();
    }

    public String toString() {
        StringWriter out = new StringWriter();
        XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint());
        try {
            writer.write(element);
        }
        catch (Exception e) {
            // Ignore.
        }
        return out.toString();
    }
View Full Code Here

        if (t == null) {
            return null;
        }

        try {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);

            t.printStackTrace(pw);
            String s = sw.toString();

            StringTokenizer tokens = new StringTokenizer(s, "\r\n\t");
            tokens.nextToken();
            tokens.nextToken();
            String line = tokens.nextToken();
View Full Code Here

    final AbstractMetaData backend = getBackend();
    final String[] properties =
        {"display-name", "grouping", "grouping.ordinal",
            "ordinal", "description", "deprecated"};

    final StringWriter writer = new StringWriter();
    PrintWriter p = new PrintWriter(writer);
    for (int i = 0; i < properties.length; i++)
    {
      final String property = properties[i];
      PropertyHelper.saveConvert(backend.getKeyPrefix(), PropertyHelper.ESCAPE_KEY, p);
      PropertyHelper.saveConvert(backend.getName(), PropertyHelper.ESCAPE_KEY, p);
      p.print('.');
      PropertyHelper.saveConvert(property, PropertyHelper.ESCAPE_KEY, p);
      p.print('=');
      PropertyHelper.saveConvert(getMetaAttribute(property, locale), PropertyHelper.ESCAPE_VALUE, p);
      p.println();
    }
    p.close();
    return writer.toString();
  }
View Full Code Here

    final AbstractMetaData backend = getBackend();
    final String[] properties =
        {"display-name", "short-name", "icon", "selected-icon", "grouping", "grouping.ordinal",
            "ordinal", "description", "deprecated"};

    final StringWriter writer = new StringWriter();
    PrintWriter p = new PrintWriter(writer);
    for (int i = 0; i < properties.length; i++)
    {
      final String property = properties[i];
      final String attribute = getMetaAttribute(property, locale);
      if (StringUtils.isEmpty(attribute))
      {
        if ("icon".equals(property) ||
            "selected-icon".equals(property) ||
            "short-name".equals(property))
        {
          continue;
        }
      }
      PropertyHelper.saveConvert(backend.getKeyPrefix(), PropertyHelper.ESCAPE_KEY, p);
      PropertyHelper.saveConvert(backend.getName(), PropertyHelper.ESCAPE_KEY, p);
      p.print('.');
      PropertyHelper.saveConvert(property, PropertyHelper.ESCAPE_KEY, p);
      p.print('=');
      PropertyHelper.saveConvert(attribute, PropertyHelper.ESCAPE_VALUE, p);
      p.println();
    }
    p.println();

    for (int i = 0; i < propertyMetaDatas.length; i++)
    {
      final EditableExpressionPropertyMetaData metaData = propertyMetaDatas[i];
      p.println(metaData.printBundleText(locale));
      p.println();
    }
    p.close();
    return writer.toString();
  }
View Full Code Here

    //往上下文中填入数据
    context.put("ctxPath", this.request.getContextPath());
    context.put("ctx", result);
    context.put("xctx",request.getSession().getAttribute(HtmlResponseWriter.OPTION_KEY));
    //输出到用户端
    StringWriter writer = new StringWriter();
    template.merge(context, writer);
    String content = writer.toString();
    out.write(content.getBytes());
  }
View Full Code Here

      throws Exception {

    this.initFreemarker();
    //获取模板
    Template template = cfg.getTemplate(annotation.success().value(), "utf-8");
    StringWriter writer = new StringWriter();
    //往上下文中填入数据
    Map context = new HashMap();
    context.put("ctx", result);
    context.put("xctx",session.getAttribute(HtmlResponseWriter.OPTION_KEY));
    template.process(context, writer);

    //输出到用户端
    writer.toString();
    out.write(writer.toString().getBytes());
  }
View Full Code Here

  public static Context getCTLContext(){
    if(ctlEngine == null)
      return null;
    Context context = ctlContext.get();
    if(context == null){
      context = ctlEngine.createContext(new StringWriter());
      ctlContext.set(context);
    }
    return context;
  }
View Full Code Here

      sslNotSupported = true;
    } catch (Exception exc) {
      exception = exc;
    }
   
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    exception.printStackTrace(pw);
    pw.close();
   
    if (sslNotSupported) {
      throw new SSLNotSupportedException("Neither JSSE nor J2SE " +
          ">= 1.4 installed:\n---\n"+
      sw.toString() +"---");
    } else {
      throw new SSLException("Exception while creating "+
          "the SSLSocketFactory with JSSE:\n---\n"+
          sw.toString() + "---");
    }
  }
View Full Code Here

     * @param element
     * @return content of <b>documentation</b> elements, or <code>null</code> if none
     */
    protected String extractDocumentation(AnnotatedBase element) {
        if (m_schemaCustom.isJavaDocDocumentation()) {
            StringWriter writer = new StringWriter();
            AnnotationElement anno = element.getAnnotation();
            if (anno != null) {
                FilteredSegmentList items = anno.getItemsList();
                for (int i = 0; i < items.size(); i++) {
                    AnnotationItem item = (AnnotationItem)items.get(i);
                    if (item instanceof DocumentationElement) {
                        DocumentationElement doc = (DocumentationElement)item;
                        List contents = doc.getContent();
                        if (contents != null) {
                            for (Iterator iter = contents.iterator(); iter.hasNext();) {
                                Node node = (Node)iter.next();
                                DOMSource source = new DOMSource(node);
                                StreamResult result = new StreamResult(writer);
                                try {
                                    s_transformer.transform(source, result);
                                } catch (TransformerException e) {
                                    s_logger.error("Failed documentation output transformation", e);
                                }
                            }
                        }
                    }
                }
            }
            StringBuffer buff = writer.getBuffer();
            if (buff.length() > 0) {
               
                // make sure there's no embedded comment end marker
                int index = buff.length();
                while ((index = buff.lastIndexOf("*/", index)) >= 0) {
View Full Code Here

TOP

Related Classes of java.io.StringWriter

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.