Package java.io

Examples of java.io.StringWriter


        }
        return replaced;
      } catch(Throwable t) {
        if (logger.isLoggable(BasicLevel.WARN))
          logger.log(BasicLevel.WARN, "replaceInterceptor", t);
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        throw new Exception("(" + newInterceptorClassName + " exc=" + sw.toString() + ')');
      }
    }
    return false;
  }
View Full Code Here


   * Prints the stack trace of the specified throwable to a
   * string and returns it.
   */
  public String stackTrace( Throwable throwable )
  {
    StringWriter sw   = new StringWriter() ;
    PrintWriter pw    = new PrintWriter( sw ) ;
    throwable.printStackTrace( pw ) ;
    pw.close() ;
    return sw.toString() ;
  } // stackTrace()
View Full Code Here

        Throwable t = res.getError();
        if (t == null)
            return null;
        else if (t instanceof ScriptingException)
            return ((ScriptingException) t).getJavaStackTrace();
        StringWriter w = new StringWriter();
        t.printStackTrace(new PrintWriter(w));
        return w.toString();
    }
View Full Code Here

        XQueryProcessor processor = new XQueryProcessor();
        XQueryModule mod = processor.parse(new FileInputStream(queryFile), new File(DOC_BASE).toURI());
        processor.compile(mod);
        System.err.println(mod.getExpression().toString());
        Sequence result = processor.execute(mod);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        ser.emit(result);
        String swresult = sw.toString();
        long used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(before GC): " + StringUtils.displayBytesSize(used));
        System.gc();
        used = SystemUtils.getHeapUsedMemory();
        stdbuf.append(", used(after GC): " + StringUtils.displayBytesSize(used));
        int gcCalled = SystemUtils.countGC() - gcBefore;
        stdbuf.append(", total gc count: " + gcCalled);
        System.out.println(swresult);
        System.out.println(stdbuf.toString());
        return res_sw.toString();
    }
View Full Code Here

        if (TVBrowser.isTransportable()) {
          mLog.info("Using default menu bar (instead of MacOSXMenuBar) for transportable version.");
        }
        mLog.warning("Could not instantiate MacOSXMenuBar\n" + e.toString());
        if (e.getCause() != null) {
          StringWriter sw = new StringWriter();
          e.getCause().printStackTrace(new PrintWriter(sw));
          mLog.warning(sw.toString());
        }
        mMenuBar = new DefaultMenuBar(this, mStatusBar.getLabel());
        mLog.info("Using default menu bar");
      }
View Full Code Here

     * {@inheritDoc}
     */
    public void invoke(OutContext context, IXMLWriter xmlWriter) throws IOException, WsException {
        xmlWriter.startTagClosed(0, ELEMENT_NAME);
        if (m_includeStackTrace) {
            StringWriter sw = new StringWriter();
            m_throwable.printStackTrace(new PrintWriter(sw));
            xmlWriter.writeTextContent(sw.toString());
        } else {
            xmlWriter.writeTextContent(m_throwable.getClass().getName() + MESSAGE_SEPARATOR
                + m_throwable.getLocalizedMessage());
        }
        xmlWriter.endTag(0, ELEMENT_NAME);
View Full Code Here

     ******************************************************************************/
    private static class XSLTransformation {
        public static String transform(String stylesheet,
                                       String srcXMLString,
                                       HashMap<String, String> params) throws Exception {
            StringWriter writer = new StringWriter();
            StreamResult result = new StreamResult( writer );
            Source src = new StreamSource( new StringReader( srcXMLString ) );
            transform( stylesheet,
                       src,
                       result,
                       params );
            return writer.toString();
        }
View Full Code Here

    }

    public void createJavaStringFromXMLString() throws Exception {
        InputStream is = getClass().getResourceAsStream(
                "HelperTestFormattingFile.xml");
        StringWriter sw = new StringWriter();
        Helper.readStreamIntoWriter(is, sw);
        String str = sw.toString();

        log.info(Helper.createJavaStringFromXMLString(str));
    }
View Full Code Here

        return newDocumentBuilder().parse(is);
    }

    public static String getDocumentAsString(Document doc)
            throws TransformerException {
        StringWriter writer = new StringWriter();

        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
        transformer.transform(new DOMSource(doc), new StreamResult(writer));

        return writer.toString();
    }
View Full Code Here

    protected Writer writer;

    @Override
    public void setUp() {
        super.setUp();
        writer = new StringWriter();
        ev1 = new Event();
        ev2 = new Event();
        ev3 = new Event();
        ev4 = new Event();
        person1 = new Person();
View Full Code Here

TOP

Related Classes of java.io.StringWriter

Copyright © 2015 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.