Package java.io

Examples of java.io.StringWriter


    errorMsg.append("' has caused an error during ");
    errorMsg.append(action).append(": ");
    errorMsg.append(e.getLocalizedMessage()).append("\n");

    // print stack trace
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter, true);
    e.printStackTrace(printWriter);
    printWriter.flush();
    stringWriter.flush();
    errorMsg.append(stringWriter.toString());

    mLog.severe(errorMsg.toString());
  }
View Full Code Here


                    "</mappingNode>" + //$NON-NLS-1$
                "</mappingNode>" + //$NON-NLS-1$
                "</xmlMapping>"; //$NON-NLS-1$
       
        MappingOutputter out = new MappingOutputter();
        StringWriter sw = new StringWriter();
        out.write(doc, new PrintWriter(sw));
       
        assertEquals(expected, sw.toString());
    }
View Full Code Here

       
        doc = XMLPlanner.preMarkExcluded(query, doc);      
        XMLPlanner.removeExcluded(doc);
       
        MappingOutputter out = new MappingOutputter();
        StringWriter sw = new StringWriter();
        out.write(doc, new PrintWriter(sw));
        String actual = sw.toString();
       
        expected = expected.replaceAll("\\s*<", "<"); //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals(expected, actual);
    }
View Full Code Here

    public Object clone() {
        // I found this as cheap way of cloneing for now fast, may be we will
        // do all the object cloneing later..
        try {
            MappingOutputter out = new MappingOutputter();
            StringWriter stream = new StringWriter();
            out.write(this, new PrintWriter(stream));
            MappingLoader loader = new MappingLoader();
            MappingDocument doc =  loader.loadDocument(new ByteArrayInputStream(stream.toString().getBytes()));

            // Copy the values of the instance variables.
            doc.formatted = this.formatted;
            doc.encoding = this.encoding;
            doc.name = this.name;
View Full Code Here

     *
     * @param obj     instance to report on
     * @return string
     */
    final public static String report(Object obj) {
        StringWriter result = new StringWriter();
        PrintWriter report = new PrintWriter(result, true);
        try {    
            if (obj != null) {
                report.print("Class: ");
                report.println(obj.getClass().getName());
                report.print("Location: ");
                CodeSource cs = obj.getClass().getProtectionDomain().getCodeSource();
                if (cs != null)
                    report.println(cs.getLocation().toString());
                else
                    report.println("unknown");
            }
            else {
                report.print("Null object supplied");               
            }
            report.print("Version: ");
            report.println(versionString);
            report.print("Build timestamp: ");
            report.println(buildTimestamp);
       
            report.print("Java version: ");
            report.println(System.getProperty("java.version"));
            report.print("CLASSPATH: ");
            report.println(System.getProperty("java.class.path"));
            report.print("OS name: ");
            report.println(System.getProperty("os.name"));
            report.print("OS arch: ");
            report.println(System.getProperty("os.arch"));
            report.print("OS version: ");
            report.println(System.getProperty("os.version"));
        }
        catch (Throwable ex) {
            report.println("Could not obtain version details: " + ex.getMessage());
        }
        return result.toString();
    }
View Full Code Here

            buf.append(Thread.currentThread().getName()).append("_");
        buf.append(clazz).append("] ").append(stamp).
        append(" : ").append(message);
        if (t != null) {
            buf.append(" : ").append(t.getMessage());
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            pw.println();
            t.printStackTrace(pw);
            pw.println();
            buf.append(sw.toString());
        }
        if (appenders.size() == 0) { // by default to stdout
            System.out.println(buf.toString());
            while (t != null) {
                t.printStackTrace(System.out);
View Full Code Here

   
    /* (non-Javadoc)
     * @see com.enterprisedt.util.debug.Appender#log(java.lang.Throwable)
     */
    public synchronized void log(Throwable t) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         t.printStackTrace(pw);
         String msg = sw.toString();
         if (!closed) {
             checkForRollover();
             log.println(msg);
             log.flush();
             thresholdBytesWritten += msg.length();
View Full Code Here

    /**
     * prints the current stacktrace
     */
    public void printStackTrace() {
      Throwable    t;
      StringWriter  writer;

      writer = new StringWriter();
     
      // generate stacktrace
      t = new Throwable();
      t.fillInStackTrace();
      t.printStackTrace(new PrintWriter(writer));

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

        try {
          interceptors.add((MessageInterceptor)Class.forName(interceptorClassName).newInstance());
        } catch(Throwable t) {
          if (logger.isLoggable(BasicLevel.WARN))
            logger.log(BasicLevel.WARN, "addInterceptors", t);
          StringWriter sw = new StringWriter();
          t.printStackTrace(new PrintWriter(sw));
          if (error == null)
            error = "(" + interceptorClassName + " exc=" + sw.toString() + ')';
          else
            error = error + "(" + interceptorClassName + " exc=" + sw.toString() + ')';
        }
      }
      if (error != null)
        throw new Exception(error);
    }
View Full Code Here

        try {
          removeInterceptor(interceptorClassName, interceptors);
        } catch(Throwable t) {
          if (logger.isLoggable(BasicLevel.WARN))
            logger.log(BasicLevel.WARN, "removeInterceptors", t);
          StringWriter sw = new StringWriter();
          t.printStackTrace(new PrintWriter(sw));
          if (error == null)
            error = "(" + interceptorClassName + " exc=" + sw.toString() + ')';
          else
            error = error + "(" + interceptorClassName + " exc=" + sw.toString() + ')';
        }
      }
      if (error != null)
        throw new Exception(error);
    }
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.