Package java.io

Examples of java.io.PrintWriter


public class SimplestHelloWorldPortlet extends GenericPortlet
{
   public void doView(RenderRequest request, RenderResponse response) throws IOException
   {
      PrintWriter writer = response.getWriter();
      writer.write("Hello World !");
      writer.close();
   }
View Full Code Here


    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$
                "</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

        // 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;
View Full Code Here

   * Creates a StreamAppender using the given stream.
   * @param outStr Stream to write logging to.
   */
  public StreamAppender(OutputStream outStr) {
    this.outStr = outStr;
    this.log = new PrintWriter(outStr);
  }
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(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) {
View Full Code Here

        this.file = file;
        open();
    }
   
    protected synchronized void open() throws IOException {
        log = new PrintWriter(new FileWriter(file, true), true);
        closed = false;
    }
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);
View Full Code Here

TOP

Related Classes of java.io.PrintWriter

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.