Like {@code print()}, but writes directly to a {@code String} and returns it.
776073
public static String printToString(UnknownFieldSet fields) {
        try {
            StringBuilder text = new StringBuilder();
            print(fields, text);
            return text.toString();
        } catch (IOException e) {
            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never "
                                                       + "happen).",
                                       e);
        }
    }
672610
@Override
    public PrintWriter getWriter() throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getWriter: " + this);
        }
        if (this.streamActive) {
            throw new IllegalStateException("Output stream already obtained");
        }
        if (null == this.outWriter) {
            this.outWriter = new PrintWriter(
                            new OutputStreamWriter(
                                            this.outStream, getCharacterEncoding()), false);
        }
        return this.outWriter;
    }
1038425
public static PrintWriter getPrintWriter(File file, String charset, boolean isAppend) throws IORuntimeException {
		return new PrintWriter(getWriter(file, charset, isAppend));
	}
788500
public String print(ReadablePartial partial) {
        StringBuilder buf = new StringBuilder(requirePrinter().estimatePrintedLength());
        try {
            printTo((Appendable) buf, partial);
        } catch (IOException ex) {
            // StringBuilder does not throw IOException
        }
        return buf.toString();
    }
147416
public static String print(PrimitiveType type) {
        return type.match(new PrimitiveType.MatchBlock<String>() {

            @Override
            public String _case(BooleanType x) {
                return "boolean";
            }

            @Override
            public String _case(ByteType x) {
                return "byte";
            }

            @Override
            public String _case(CharType x) {
                return "char";
            }

            @Override
            public String _case(DoubleType x) {
                return "double";
            }

            @Override
            public String _case(FloatType x) {
                return "float";
            }

            @Override
            public String _case(IntType x) {
                return "int";
            }

            @Override
            public String _case(LongType x) {
                return "long";
            }

            @Override
            public String _case(ShortType x) {
                return "short";
            }});
    }
1015080
public static String asString( Example example )
    {
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter( sw );
        example.print( writer );
        return sw.toString();
    }
1366718
public void println(String value) {
        print(value);
        out.println();
        out.flush();
        newLine = true;
    }
322639
public PrintWriter getWriter()
        throws java.io.IOException 
    {
        if (_outputState==DISABLED)
            return __nullServletWriter;
                                   
        if (_outputState!=NO_OUT && _outputState!=WRITER_OUT)
            throw new IllegalStateException();

        // If we are switching modes, flush output to try avoid overlaps.
        if (_out!=null)
            _out.flush();
        
        /* if there is no writer yet */
        if (_writer==null)
        {
            /* get encoding from Content-Type header */
            String encoding = _httpResponse.getCharacterEncoding();
            
            if (encoding==null)
            {
                if (_servletHttpRequest!=null)
                {
                    /* implementation of educated defaults */
                    String mimeType = _httpResponse.getMimeType();                
                    encoding = _servletHttpRequest.getServletHandler()
                    	.getHttpContext().getEncodingByMimeType(mimeType);
                }
                if (encoding==null)
                    encoding = StringUtil.__ISO_8859_1; 
                _httpResponse.setCharacterEncoding(encoding,true);
            }
            
            /* construct Writer using correct encoding */
            _writer = new ServletWriter(_httpResponse.getOutputStream(), encoding);
        }                    
        _outputState=WRITER_OUT;
        return _writer;
    }
1322648
public static String print(final Object value) {
        if (value == null) {
            return "null";
        }
        if (value instanceof String) {
            return '"' + value.toString() + '"';
        }
        if (value instanceof Character) {
            return printChar((Character) value);
        }
        if (value instanceof Long) {
            return value + "L";
        }
        if (value instanceof Double) {
            return value + "d";
        }
        if (value instanceof Float) {
            return value + "f";
        }
        if (value instanceof Short) {
            return "(short) " + value;
        }
        if (value instanceof Byte) {
            return String.format("(byte) 0x%02X", (Byte) value);
        }
        if (value instanceof Map) {
            return printMap((Map<?, ?>) value);
        }
        if (value.getClass().isArray()) {
            return printValues("[", ", ", "]", new Iterator<Object>() {
                private int currentIndex = 0;

                public boolean hasNext() {
                    return currentIndex < Array.getLength(value);
                }

                public Object next() {
                    return Array.get(value, currentIndex++);
                }

                public void remove() {
                    throw new UnsupportedOperationException("cannot remove items from an array");
                }
            });
        }
        if (value instanceof FormattedText) {
            return (((FormattedText) value).getText());
        }

        return descriptionOf(value);
    }
752003
public static final String throwableToString(Throwable t) {
        final StringWriter s = new StringWriter();
        final PrintWriter p = new PrintWriter(s);

        if (t == null) {
            p.println("none");
        } else {
            printStackTrace(p, t);
        }

        return DataFormatHelper.escape(s.toString());
    }
1280503
public synchronized void print(java.io.PrintWriter printWriter)
    {
        printWriter.println("Dump of TreeMap size=" + size + "(long)");
        try {
            for (Iterator iterator = entrySet().iterator(); iterator.hasNext();) {
                Entry entry = (Entry) iterator.next();
                printWriter.println((indexLabel(entry) + "                    ").substring(0, 20)
                                    + (entry.getColor() ? " RED  " : " BLACK")
                                    + " Entry=" + entry);
            } // for(iterator... 
        } catch (ObjectManagerException objectManagerException) {
            // No FFDC code needed.
            printWriter.println("Caught objectManagerException=" + objectManagerException);
            objectManagerException.printStackTrace(printWriter);
        } // try...   
    }
800218
public void print(char c) throws IOException
    {
        if(this._listener!= null &&  !checkIfCalledFromWLonError()){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())    
                Tr.debug(tc, "non blocking print char , WriteListener enabled: " + this._listener);
            this.print_NonBlocking(Character.toString(c));
        }
        else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())    
                Tr.debug(tc, "print char");
            super.print(c);
        }    
    }
877791
public static void println(Object self) {
        // we won't get here if we are a PrintWriter
        if (self instanceof Writer) {
            PrintWriter pw = new GroovyPrintWriter((Writer) self);
            pw.println();
        } else {
            System.out.println();
        }
    }
179589
public static String print(Type type) {
        return type.match(new Type.MatchBlock<String>(){
            @Override
            public String _case(Ref x) {
                return print(x.type);
            }

            @Override
            public String _case(Primitive x) {
                return print(x.type);
            }
            
        });
    }
864277
public void printThrowable(Throwable t) {
        final PrintContext context = new PrintContext();

        Throwable prevThrowable = null;
        Throwable currentThrowable = t;
        while (true) {
            printThrowable0(context, currentThrowable, prevThrowable);
            final Throwable nextThrowable = currentThrowable.getCause();
            if (currentThrowable != nextThrowable && nextThrowable != null) {
                prevThrowable = currentThrowable;
                currentThrowable = nextThrowable;
                context.append("Caused by: ");
            } else {
                break;
            }
        }
    }
508933
public static PrintStmt get(final IPrintStatement<?> _printStmt,
                                final StmtFlag... _flags)
    {
        final PrintStmt ret = new PrintStmt(_flags);
        ret.setEQLStmt(_printStmt);
        return ret;
    }
698031
public static String printNode(Node node, boolean prettyprint)
   {
      StringWriter strw = new StringWriter();
      new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
      return strw.toString();
   }