Package org.nutz.lang.stream

Examples of org.nutz.lang.stream.StringOutputStream


    @Test
    public void testPersonObject() throws Exception {
        Person p = Json.fromJson(Person.class,
                                 getFileAsInputStreamReader("org/nutz/json/person.txt"));
        StringBuilder sb = new StringBuilder();
        Writer w = new OutputStreamWriter(new StringOutputStream(sb));
        w.write(p.dump());
        w.write("\n");
        w.write(p.getFather().dump());
        w.write("\n");
        w.write(p.getCompany().getName());
View Full Code Here


     * @param sb
     *            StringBuilder 对象
     * @return 输出流对象
     */
    public static StringOutputStream ops(StringBuilder sb) {
        return new StringOutputStream(sb);
    }
View Full Code Here

     *            抛出对象
     * @return 异常堆栈文本
     */
    public static String getStackTrace(Throwable e) {
        StringBuilder sb = new StringBuilder();
        StringOutputStream sbo = new StringOutputStream(sb);
        PrintStream ps = new PrintStream(sbo);
        e.printStackTrace(ps);
        ps.flush();
        return sbo.getStringBuilder().toString();
    }
View Full Code Here

     *
     * @throws IOException
     */
    String dumpAsString() throws IOException {
        StringBuilder sb = new StringBuilder();
        OutputStream ops = new StringOutputStream(sb, Encoding.defaultEncoding());
        dump(ops);
        return sb.toString();
    }
View Full Code Here

     *
     * @throws IOException
     */
    public String dumpAsString(String charset) throws IOException {
        StringBuilder sb = new StringBuilder();
        OutputStream ops = new StringOutputStream(sb, charset);
        dump(ops);
        return sb.toString();
    }
View Full Code Here

         *            显示 HTTP 头信息的模式: MODE.ALL or MODE.HEADER_ONLY
         * @return 一个文本字符串表示 HTTP 的全部内容
         */
        public static String http(HttpServletRequest req, MODE mode) {
            StringBuilder sb = new StringBuilder();
            OutputStream ops = new StringOutputStream(sb,
                                                      req.getCharacterEncoding());
            http(req, ops, mode);
            return sb.toString();
        }
View Full Code Here

TOP

Related Classes of org.nutz.lang.stream.StringOutputStream

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.